예제 #1
0
 protected function canHandle(Component $component, WrappedEntity $wrappedEntity)
 {
     if (!$component instanceof BaseControl && !$component instanceof Container) {
         return FALSE;
     }
     if (!$wrappedEntity->hasField($component->getName())) {
         return FALSE;
     }
     return TRUE;
 }
예제 #2
0
 protected function canHandle(Component $component, WrappedEntity $wrappedEntity)
 {
     if (!$component instanceof TextBase) {
         return FALSE;
     }
     if (!$wrappedEntity->hasField($component->getName())) {
         return FALSE;
     }
     $mapping = $wrappedEntity->getMetadata()->getFieldMapping($component->getName());
     return in_array($mapping['type'], ['date', 'time', 'datetime']);
 }
예제 #3
0
 /**
  * @param WrappedEntity $wrappedEntity
  * @param Component $component
  */
 protected function canHandle(WrappedEntity $wrappedEntity, Component $component)
 {
     if (!$component instanceof Container && !$component instanceof MultiChoiceControl) {
         return FALSE;
     }
     if (!$wrappedEntity->getMetadata()->hasAssociation($component->getName())) {
         return FALSE;
     }
     if (!$wrappedEntity->isToManyAssociation($component->name)) {
         return FALSE;
     }
     return TRUE;
 }
예제 #4
0
 private function prepareCollection()
 {
     $this->forRemoval = $this->byPrimary = $this->groupByPrimaryHash();
     $originalCollection = $this->wrappedEntity->getRawValue($this->component->name);
     if (!$originalCollection instanceof Collection && $originalCollection !== NULL) {
         throw new UnexpectedValueException("Instance of \\Doctrine\\Common\\Collections\\Collection expected, " . (is_object($originalCollection) ? get_class($originalCollection) : gettype($originalCollection)) . ' given');
     }
     $this->collection = new ArrayCollection($originalCollection ? $originalCollection->toArray() : []);
 }
예제 #5
0
 /**
  * @param WrappedEntity $wrappedEntity
  * @param Container $component
  * @param array $association
  * @return null|object
  */
 protected function getRelatedEntity(WrappedEntity $wrappedEntity, Container $component, $association)
 {
     $relatedEntity = $wrappedEntity->getValue($component->name);
     if ($relatedEntity === NULL) {
         $className = $association['targetEntity'];
         $entityManager = $wrappedEntity->getEntityManager();
         $metadata = $entityManager->getClassMetadata($className);
         $identifierFields = $metadata->identifier;
         $data = $component->getValues(TRUE);
         $relatedEntityIdentifier = $this->getIdentifierFromArray($identifierFields, $data);
         if ($relatedEntityIdentifier) {
             $repository = $entityManager->getRepository($className);
             $relatedEntity = $repository->find($relatedEntityIdentifier);
         }
         if (!$relatedEntity) {
             $relatedEntity = $metadata->newInstance();
         }
     }
     return $relatedEntity;
 }