/**
  * Validate object
  *
  * @param mixed $object
  * @throws \TYPO3\CMS\Extbase\Reflection\Exception\PropertyNotAccessibleException
  * @throws \InvalidArgumentException
  * @return boolean|\TYPO3\CMS\Extbase\Error\Result
  */
 public function validate($object)
 {
     $messages = new \TYPO3\CMS\Extbase\Error\Result();
     if (self::$instancesCurrentlyUnderValidation === NULL) {
         self::$instancesCurrentlyUnderValidation = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
     }
     if ($object === NULL) {
         return $messages;
     }
     if (!$this->canValidate($object)) {
         $messages->addError(\TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('error_notvalidatable', 'StoreFinder'), 1301599551);
         return $messages;
     }
     if (self::$instancesCurrentlyUnderValidation->contains($object)) {
         return $messages;
     } else {
         self::$instancesCurrentlyUnderValidation->attach($object);
     }
     $this->model = $object;
     $propertyValidators = $this->getValidationRulesFromSettings();
     foreach ($propertyValidators as $propertyName => $validatorsNames) {
         if (!property_exists($object, $propertyName)) {
             $messages->addError(\TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('error_notexists', 'StoreFinder'), 1301599575);
         } else {
             $this->currentPropertyName = $propertyName;
             $propertyValue = $this->getPropertyValue($object, $propertyName);
             $this->checkProperty($propertyValue, (array) $validatorsNames, $messages->forProperty($propertyName));
         }
     }
     self::$instancesCurrentlyUnderValidation->detach($object);
     return $messages;
 }
 /**
  * Removes an object to the persistence.
  *
  * @param object $object The object to remove
  * @return void
  * @api
  */
 public function remove($object)
 {
     if ($this->addedObjects->contains($object)) {
         $this->addedObjects->detach($object);
     } else {
         $this->removedObjects->attach($object);
     }
 }
Esempio n. 3
0
 /**
  * Unregister an object
  *
  * @param object $object
  * @return void
  */
 public function unregisterObject($object)
 {
     unset($this->identifierMap[strtolower(get_class($object))][$this->objectMap[$object]]);
     $this->objectMap->detach($object);
 }
 /**
  *
  *
  * @param \TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface $object
  * @param string $fieldname
  * @param \Iterator $fileReferences
  * @param string $key
  * @throws \Exception
  */
 public function saveAll(\TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface $object, $fieldname, \TYPO3\CMS\Extbase\Persistence\ObjectStorage $fileReferences, $key = '')
 {
     $someSavedAlready = FALSE;
     $savableReferences = array();
     foreach ($fileReferences as $ref) {
         if (!$ref instanceof FileReference) {
             $fileReferences->detach($ref);
             continue;
         }
         $savableReferences[] = $ref;
         $uid = $ref->getUid();
         if ($uid) {
             $someSavedAlready = TRUE;
             $keepers[] = $uid;
         }
     }
     // This is a new $object, unlikely to have any existing FileReferences for this field.
     if (!$object->getUid() || !$someSavedAlready) {
         $i = 0;
         foreach ($savableReferences as $ref) {
             $this->save($ref, $key);
             $this->limbo->clearHeld($key . '.' . $i++);
         }
         return;
     }
     // Remove FileReferences for this field, unless we're keeping them.
     $datamap = $this->dataMapper->getDataMap(get_class($object));
     $this->removeFileReferences($object->getUid(), $datamap->getTableName(), $fieldname, $keepers);
     // Save any new ones
     $i = 0;
     foreach ($savableReferences as $ref) {
         $this->save($ref, $key);
         // We need to do this because, no matter which reference
         // is loaded, we need to clear the them all. And $this->save()
         // doesn't do that exactly.
         $this->limbo->clearHeld($key . '.' . $i++);
     }
 }
Esempio n. 5
0
 /**
  * @param object $object The object to remove.
  *
  * @see \TYPO3\CMS\Extbase\Persistence\ObjectStorage::detach
  */
 public function detach($object)
 {
     $this->initialize();
     parent::detach($object);
 }