/** * Call the view helper associated with this object. * * First, it evaluates the arguments of the view helper. * * If the view helper implements \TYPO3\CMS\Fluid\Core\ViewHelper\Facets\ChildNodeAccessInterface, * it calls setChildNodes(array childNodes) on the view helper. * * Afterwards, checks that the view helper did not leave a variable lying around. * * @param \TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext * @return string evaluated node after the view helper has been called. */ public function evaluate(\TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext) { if ($this->viewHelpersByContext->contains($renderingContext)) { $viewHelper = $this->viewHelpersByContext[$renderingContext]; $viewHelper->resetState(); } else { $viewHelper = clone $this->uninitializedViewHelper; $this->viewHelpersByContext->attach($renderingContext, $viewHelper); } $evaluatedArguments = array(); if (count($viewHelper->prepareArguments())) { foreach ($viewHelper->prepareArguments() as $argumentName => $argumentDefinition) { if (isset($this->arguments[$argumentName])) { $argumentValue = $this->arguments[$argumentName]; $evaluatedArguments[$argumentName] = $argumentValue->evaluate($renderingContext); } else { $evaluatedArguments[$argumentName] = $argumentDefinition->getDefaultValue(); } } } $viewHelper->setArguments($evaluatedArguments); $viewHelper->setViewHelperNode($this); $viewHelper->setRenderingContext($renderingContext); if ($viewHelper instanceof \TYPO3\CMS\Fluid\Core\ViewHelper\Facets\ChildNodeAccessInterface) { $viewHelper->setChildNodes($this->childNodes); } $output = $viewHelper->initializeArgumentsAndRender(); return $output; }
/** * 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); } }
/** * Checks whether the given object is known to the identity map * * @param object $object * @return bool * @api */ public function hasObject($object) { return $this->objectMap->contains($object); }
/** * Renders the header of a given object/collection. It is usually the class name along with some flags. * * @param object $object * @param int $level * @param bool $plainText * @param bool $ansiColors * @return string The rendered header with tags */ protected static function renderHeader($object, $level, $plainText, $ansiColors) { $dump = ''; $persistenceType = ''; $className = get_class($object); $classReflection = new \ReflectionClass($className); if ($plainText) { $dump .= self::ansiEscapeWrap($className, '36', $ansiColors); } else { $dump .= '<span class="extbase-debug-type">' . $className . '</span>'; } if ($object instanceof \TYPO3\CMS\Core\SingletonInterface) { $scope = 'singleton'; } else { $scope = 'prototype'; } if ($plainText) { $dump .= ' ' . self::ansiEscapeWrap($scope, '44;37', $ansiColors); } else { $dump .= $scope ? '<span class="extbase-debug-scope">' . $scope . '</span>' : ''; } if ($object instanceof \TYPO3\CMS\Extbase\DomainObject\AbstractDomainObject) { if ($object->_isDirty()) { $persistenceType = 'modified'; } elseif ($object->_isNew()) { $persistenceType = 'transient'; } else { $persistenceType = 'persistent'; } } if ($object instanceof \TYPO3\CMS\Extbase\Persistence\ObjectStorage && $object->_isDirty()) { $persistenceType = 'modified'; } if ($object instanceof \TYPO3\CMS\Extbase\DomainObject\AbstractEntity) { $domainObjectType = 'entity'; } elseif ($object instanceof \TYPO3\CMS\Extbase\DomainObject\AbstractValueObject) { $domainObjectType = 'valueobject'; } else { $domainObjectType = 'object'; } if ($plainText) { $dump .= ' ' . self::ansiEscapeWrap($persistenceType . ' ' . $domainObjectType, '42;30', $ansiColors); } else { $dump .= '<span class="extbase-debug-ptype">' . ($persistenceType ? $persistenceType . ' ' : '') . $domainObjectType . '</span>'; } if (strpos(implode('|', self::$blacklistedClassNames), get_class($object)) > 0) { if ($plainText) { $dump .= ' ' . self::ansiEscapeWrap('filtered', '47;30', $ansiColors); } else { $dump .= '<span class="extbase-debug-filtered">filtered</span>'; } } elseif (self::$renderedObjects->contains($object) && !$plainText) { $dump = '<a href="javascript:;" onclick="document.location.hash=\'#' . spl_object_hash($object) . '\';" class="extbase-debug-seeabove">' . $dump . '<span class="extbase-debug-filtered">see above</span></a>'; } elseif ($level >= self::$maxDepth && !$object instanceof \DateTime) { if ($plainText) { $dump .= ' ' . self::ansiEscapeWrap('max depth', '47;30', $ansiColors); } else { $dump .= '<span class="extbase-debug-filtered">max depth</span>'; } } elseif ($level > 1 && !$object instanceof \DateTime && !$plainText) { if ($object instanceof \Countable && empty($object) || empty($classReflection->getProperties())) { $dump = '<span>' . $dump . '</span>'; } else { $dump = '<input type="checkbox" id="' . spl_object_hash($object) . '" /><span class="extbase-debug-header">' . $dump . '</span>'; } } if ($object instanceof \Countable) { $objectCount = count($object); $dump .= $objectCount > 0 ? ' (' . $objectCount . ' items)' : ' (empty)'; } if ($object instanceof \DateTime) { $dump .= ' (' . $object->format(\DateTime::RFC3339) . ', ' . $object->getTimestamp() . ')'; } if ($object instanceof \TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface && !$object->_isNew()) { $dump .= ' (uid=' . $object->getUid() . ', pid=' . $object->getPid() . ')'; } return $dump; }
/** * @param object $object The object to look for. * @return boolean * * @see \TYPO3\CMS\Extbase\Persistence\ObjectStorage::contains */ public function contains($object) { $this->initialize(); return parent::contains($object); }