Пример #1
0
    /**
     * 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;
    }
Пример #2
0
 public function __construct($queryMap = null, $namespaces = null, $xpath = null)
 {
     parent::__construct();
     $this->setQueryMap($queryMap);
     $this->setNamespaces($namespaces);
     $this->setXPath($xpath);
 }
Пример #3
0
 /**
  * Define if extract values will use camel case or name with underscore
  * @param bool|array $underscoreSeparatedKeys
  */
 public function __construct($underscoreSeparatedKeys = true)
 {
     parent::__construct();
     $this->setUnderscoreSeparatedKeys($underscoreSeparatedKeys);
     $this->filterComposite->addFilter("is", new IsFilter());
     $this->filterComposite->addFilter("has", new HasFilter());
     $this->filterComposite->addFilter("get", new GetFilter());
     $this->filterComposite->addFilter("parameter", new NumberOfParameterFilter(), FilterComposite::CONDITION_AND);
 }
Пример #4
0
 /**
  * @param ObjectManager     $objectManager
  * @param HydratorInterface $hydrator
  */
 public function __construct(ObjectManager $objectManager, HydratorInterface $hydrator = null)
 {
     $this->objectManager = $objectManager;
     if (null === $hydrator) {
         $hydrator = new ClassMethodsHydrator(false);
     }
     $this->setHydrator($hydrator);
     parent::__construct();
 }
Пример #5
0
 /**
  * Define if extract values will use camel case or name with underscore
  * @param bool|array $underscoreSeparatedKeys
  */
 public function __construct($underscoreSeparatedKeys = true)
 {
     parent::__construct();
     $this->setUnderscoreSeparatedKeys($underscoreSeparatedKeys);
     $this->callableMethodFilter = new OptionalParametersFilter();
     $this->filterComposite->addFilter('is', new IsFilter());
     $this->filterComposite->addFilter('has', new HasFilter());
     $this->filterComposite->addFilter('get', new GetFilter());
     $this->filterComposite->addFilter('parameter', new OptionalParametersFilter(), FilterComposite::CONDITION_AND);
 }
Пример #6
0
 public function __construct()
 {
     parent::__construct();
     $this->init();
 }
Пример #7
0
 /**
  * Define if extract values will use camel case or name with underscore
  * @param boolean $underscoreSeparatedKeys
  */
 public function __construct($underscoreSeparatedKeys = true)
 {
     parent::__construct();
     $this->underscoreSeparatedKeys = $underscoreSeparatedKeys;
 }
Пример #8
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);
 }
Пример #9
0
 public function __construct()
 {
     parent::__construct();
     $this->init();
     $this->excludeMethods = array();
 }
 /**
  * Add filters to the Hydrator based on a predefined configuration format, if specified.
  *
  * @param AbstractHydrator        $hydrator
  * @param ServiceLocatorInterface $serviceManager
  * @param                         $config
  * @param                         $objectManager
  */
 protected function configureHydratorFilters($hydrator, $serviceManager, $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 (!$serviceManager->has($filterService)) {
             throw new ServiceNotCreatedException(sprintf('Invalid filter %s for field %s: service does not exist', $filterService, $name));
         }
         $filterService = $serviceManager->get($filterService);
         if (!$filterService instanceof FilterInterface) {
             throw new InvalidCallbackException(sprintf('Filter service %s must implement FilterInterface'), get_class($filterService));
         }
         if ($filterService instanceof ObjectManagerAwareInterface) {
             $filterService->setObjectManager($objectManager);
         }
         $hydrator->addFilter($name, $filterService, $condition);
     }
 }
Пример #11
0
 /**
  * {@inheritDoc}
  * @throws InvalidArgumentException If a strategy added to a collection does not extend AbstractCollectionStrategy
  */
 public function addStrategy($name, StrategyInterface $strategy)
 {
     if ($this->metadata->hasAssociation($name)) {
         if (!$strategy instanceof Strategy\AbstractCollectionStrategy) {
             throw new InvalidArgumentException(sprintf('Strategies used for collections valued associations must inherit from ' . 'Strategy\\AbstractCollectionStrategy, %s given', get_class($strategy)));
         }
         $strategy->setCollectionName($name)->setClassMetadata($this->metadata);
     }
     return parent::addStrategy($name, $strategy);
 }
 /**
  * {@inheritDoc}
  */
 public function removeNamingStrategy()
 {
     $this->resetCaches();
     return parent::removeNamingStrategy();
 }
Пример #13
0
 /**
  * Constructor
  *
  * @param Mandango $objectManager The ObjectManager to use
  * @param string   $modelClass    The FQCN of the hydrated/extracted object
  */
 public function __construct(Mandango $mandango, $modelClass)
 {
     parent::__construct();
     $this->mandango = $mandango;
     $this->metadata = $mandango->getMetadata($modelClass);
 }