src/Callbacks/CallbackVisitor.php
/**
     * Prepare the callbacks defined in the system configuration.
     *
     * @param \TechDivision\Import\Subjects\SubjectInterface $subject   The subject to prepare the callbacks for
     * @param array                                          $callbacks The array with the callbacks
     * @param string                                         $type      The actual callback type
     *
     * @return void
     */
Prepare the callbacks defined in the system configuration.
@param \TechDivision\Import\Subjects\SubjectInterface $subject   The subject to prepare the callbacks for
@param array                                          $callbacks The array with the callbacks
@param string                                         $type      The actual callback type

@return void
Prepare the callbacks defined in the system configuration . @param \ TechDivision \ Import \ Subjects \ SubjectInterface $subject The subject to prepare the callbacks for @param array $callbacks The array with the callbacks @param string $type The actual callback type @return void
protected function prepareCallbacks(SubjectInterface $subject, array $callbacks, $type = null)
    {
        foreach ($callbacks as $key => $callback) {
            if ($type == null) {
                $type = $key;
            }
            if (is_array($callback)) {
                $this->prepareCallbacks($subject, $callback, $type);
            } else {
                $instance = $this->container->get($callback);
                if ($instance instanceof CallbackFactoryInterface) {
                    $subject->registerCallback($instance->createCallback($subject), $type);
                } elseif ($instance instanceof CallbackInterface) {
                    $subject->registerCallback($instance, $type);
                } else {
                    throw new \InvalidArgumentException(
                        sprintf(
                            'Instance of "%s" doesn\'t implement interface "%s" or "%s"',
                            $callback,
                            CallbackFactoryInterface::class,
                            CallbackInterface::class
                        )
                    );
                }
            }
        }
    }
protected function prepareCallbacks ( SubjectInterface $ subject , array $ callbacks , $ type = null ) { foreach ( $ callbacks as $ key => $ callback ) { if ( $ type == null ) { $ type = $ key ; } if ( is_array ( $ callback ) ) { $ this -> prepareCallbacks ( $ subject , $ callback , $ type ) ; } else { $ instance = $ this -> container -> get ( $ callback ) ; if ( $ instance instanceof CallbackFactoryInterface ) { $ subject -> registerCallback ( $ instance -> createCallback ( $ subject ) , $ type ) ; } elseif ( $ instance instanceof CallbackInterface ) { $ subject -> registerCallback ( $ instance , $ type ) ; } else { throw new \ InvalidArgumentException ( sprintf ( 'Instance of "%s" doesn\'t implement interface "%s" or "%s"' , $ callback , CallbackFactoryInterface :: class , CallbackInterface :: class ) ) ; } } } }
Prepare the callbacks defined in the system configuration.
Prepare the callbacks defined in the system configuration .
// iterate over the array with callbacks and prepare them // we have to initialize the type only on the first level // query whether or not we've an subarry or not // create the instance of the callback/factory // query whether or not a factory has been specified