Пример #1
0
 /**
  * Constructor
  */
 public function __construct()
 {
     parent::__construct();
     $this->setNamingStrategy(new MapNamingStrategy($this->map));
     $this->init();
 }
Пример #2
0
 /**
  * Creates a social profiles collection hydrator.
  *
  * @param array $profileClassMap
  */
 public function __construct(array $profileClassMap = array())
 {
     parent::__construct();
     $this->profileClassMap = array_merge($this->profileClassMap, $profileClassMap);
 }
 /**
  * Constructor
  *
  * @param ObjectManager $objectManager The ObjectManager to use
  * @param bool          $byValue       If set to true, hydrator will always use entity's public API
  */
 public function __construct(ObjectManager $objectManager, $byValue = true)
 {
     parent::__construct();
     $this->objectManager = $objectManager;
     $this->byValue = (bool) $byValue;
 }
Пример #4
0
 public function __construct()
 {
     parent::__construct();
     $this->init();
 }
 /**
  * Add filters to the Hydrator based on a predefined configuration format, if specified.
  *
  * @param AbstractHydrator   $hydrator
  * @param ContainerInterface $container
  * @param array              $config
  * @param ObjectManager      $objectManager
  *
  * @throws ServiceNotCreatedException
  */
 protected function configureHydratorFilters($hydrator, ContainerInterface $container, $config, $objectManager)
 {
     if (!$hydrator instanceof FilterEnabledInterface || !isset($config['filters']) || !is_array($config['filters'])) {
         return;
     }
     foreach ($config['filters'] as $name => $filterConfig) {
         $conditionMap = array('and' => FilterComposite::CONDITION_AND, 'or' => FilterComposite::CONDITION_OR);
         $condition = isset($filterConfig['condition']) ? $conditionMap[$filterConfig['condition']] : FilterComposite::CONDITION_OR;
         $filterService = $filterConfig['filter'];
         if (!$container->has($filterService)) {
             throw new ServiceNotCreatedException(sprintf('Invalid filter %s for field %s: service does not exist', $filterService, $name));
         }
         $filterService = $container->get($filterService);
         if (!$filterService instanceof FilterInterface) {
             throw new ServiceNotCreatedException(sprintf('Filter service %s must implement FilterInterface', get_class($filterService)));
         }
         if ($filterService instanceof ObjectManagerAwareInterface) {
             $filterService->setObjectManager($objectManager);
         }
         $hydrator->addFilter($name, $filterService, $condition);
     }
 }
Пример #6
0
 /**
  * {@inheritDoc}
  */
 public function removeNamingStrategy()
 {
     $this->resetCaches();
     return parent::removeNamingStrategy();
 }