Doctrine MongoDB ODM
  1. Doctrine MongoDB ODM
  2. MODM-30

yaml lifecycleCallbacks param expects an array not string

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.0.0ALPHA1
    • Fix Version/s: None
    • Component/s: Mapping Drivers
    • Labels:
      None

      Description

      In the manual, when configuring lifecycleCallbacks

        lifecycleCallbacks:
          doStuffOnPrePersist: prePersist
          doStuffOnPostPersist: postPersist
      

      it seems, that event name must be the key not the value

        lifecycleCallbacks:
          prePersist: doStuffOnPrePersist
          postPersist: doStuffOnPostPersist
      

      and when parsing it is expecting an array not a string

      maybe a fix would be :

      // Doctrine/ODM/MongoDB/Mapping/Driver/YamlDriver.php  line 123
      if (isset($element['lifecycleCallbacks'])) {
                  foreach ($element['lifecycleCallbacks'] as $type => $methods) {
      if(!is_array($methods)){
      $methods = array($methods);
      }
                      foreach ($methods as $method) {
                          $class->addLifecycleCallback($method, constant('Doctrine\ODM\MongoDB\ODMEvents::' . $type));
                      }
                  }
              }
      

        Activity

        Hide
        Jonathan H. Wage added a comment -

        Hi, where in the documentation do you see that example?

        Show
        Jonathan H. Wage added a comment - Hi, where in the documentation do you see that example?
        Hide
        Jonathan H. Wage added a comment -

        I fixed the issue in the code but I can't locate the example documentation you are pasting to fix.

        Show
        Jonathan H. Wage added a comment - I fixed the issue in the code but I can't locate the example documentation you are pasting to fix.
        Hide
        Jonathan H. Wage added a comment -

        Actually, I changed my mind. It will always require an array and we'll fix any wrong documentation. So this would be correct:

        lifecycleCallbacks:
            prePersist: [doStuffOnPrePersist]
            postPersist: [doStuffOnPostPersist]
        
        Show
        Jonathan H. Wage added a comment - Actually, I changed my mind. It will always require an array and we'll fix any wrong documentation. So this would be correct: lifecycleCallbacks: prePersist: [doStuffOnPrePersist] postPersist: [doStuffOnPostPersist]
        Hide
        julien rollin added a comment -

        Hi,
        weird, i searched in tests units too, but i cant find it anymore...
        sorry, i certainly did a mistake

        Show
        julien rollin added a comment - Hi, weird, i searched in tests units too, but i cant find it anymore... sorry, i certainly did a mistake

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            julien rollin
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: