/** * * @param Config\AbstractConfig $cfg * @param ActivatorFactory $activatorFactory * @param InjectorFactory $injectorFactory */ public function __construct(Config\AbstractConfig $cfg, ActivatorFactory $activatorFactory = null, InjectorFactory $injectorFactory = null) { $this->registry = new Registry(); $this->config = new ArrayResolver($cfg->load()); $this->parameters = $this->config->resolve('parameters', array()); $this->classes = $this->config->resolve('classes', array()); $this->activatorFactory = $activatorFactory ?: new ActivatorFactory(); $this->injectorFactory = $injectorFactory ?: new InjectorFactory(); $this->encapsulatorFactory = new EncapsulatorFactory(); $this->referenceResolver = new ReferenceResolver($this); }
/** * Test removal */ protected function test_removal() { $this->test_append(); $this->record(); $iterations = 0; while ($iterations < $this->iterations) { self::$array->offsetUnset($iterations); ++$iterations; } }
/** * {@inheritdoc} */ public function slice($offset = 0, $length = null) { if ($this->entities instanceof CollectionInterface) { $collection = $this->entities->slice($offset, $length); } else { $slice = array_slice($this->entities, $offset, $length); $collection = new Collection($slice); } $collection->setReadOnly($this->isReadOnly()); return $collection; }
/** * @param ResourceContract $resource * @param $resourceDefinition * @param EntityFactoryContract $factory * @param mixed|null $entity * @param ContextContract $context * @return mixed $entity */ public function toEntity(ResourceContract $resource, $resourceDefinition, EntityFactoryContract $factory, Context $context, $entity = null) { $resourceDefinition = ResourceDefinitionLibrary::make($resourceDefinition); if ($entity === null) { $entity = $factory->createEntity($resourceDefinition->getEntityClassName(), $context); } $this->parents->push($entity); $values = $resource->getProperties()->getValues(); foreach ($values as $property) { $property->toEntity($entity, $this, $this->propertyResolver, $this->propertySetter, $factory, $context); } $this->parents->pop(); return $entity; }