protected function loadGettersSetters() { $methods = []; foreach ($this->reflection->getMethods() as $method) { $methods[strtolower($method->name)] = $method; } foreach ($this->metadata->getProperties() as $name => $property) { $getter = 'getter' . strtolower($name); if (isset($methods[$getter])) { $property->hasGetter = TRUE; } $setter = 'setter' . strtolower($name); if (isset($methods[$setter])) { $property->hasSetter = TRUE; } } }
protected function onRefresh(array $data) { foreach ($this->metadata->getProperties() as $name => $metadataProperty) { if (!$metadataProperty->isVirtual && isset($data[$name])) { $this->internalSetValue($metadataProperty, $name, $data[$name]); } } }
protected function onLoad(array $data) { foreach ($this->metadata->getProperties() as $name => $metadataProperty) { if (!$metadataProperty->isVirtual && isset($data[$name])) { $this->data[$name] = $data[$name]; } } $this->persistedId = $this->getterId(); }
protected function initPrimaryKey() { $primaryKey = array_values(array_filter(array_map(function (PropertyMetadata $metadata) { return $metadata->isPrimary && !$metadata->isVirtual ? $metadata->name : null; }, $this->metadata->getProperties()))); if (empty($primaryKey)) { throw new InvalidStateException("Entity {$this->reflection->name} does not have defined any primary key."); } elseif (!$this->metadata->hasProperty('id') || !$this->metadata->getProperty('id')->isPrimary) { throw new InvalidStateException("Entity {$this->reflection->name} has to have defined \$id property as {primary} or {primary-proxy}."); } $this->metadata->setPrimaryKey($primaryKey); }
protected function attached($form) { parent::attached($form); $this->setCurrentGroup($this->getForm()->addGroup($this->prefixContainer('group'))); $this->addProperties($this->metadata->getProperties()); }