Example #1
0
 /**
  * Initializes the Object framework.
  *
  * @return void
  * @see initialize()
  */
 public function initializeConfiguration($configuration)
 {
     $this->configurationManager = $this->objectManager->get('Tx_Extbase_Configuration_ConfigurationManagerInterface');
     $contentObject = isset($this->cObj) ? $this->cObj : t3lib_div::makeInstance('tslib_cObj');
     $this->configurationManager->setContentObject($contentObject);
     $this->configurationManager->setConfiguration($configuration);
 }
 /**
  * This is the main method that is called when a task is executed
  * It MUST be implemented by all classes inheriting from this one
  * Note that there is no error handling, errors and failures are expected
  * to be handled and logged by the client implementations.
  * Should return TRUE on successful execution, FALSE on error.
  *
  * @return boolean Returns TRUE on successful execution, FALSE on error
  */
 public function execute()
 {
     $this->setupFramework();
     $dropboxSync = $this->objectManager->get('Tx_DlDropboxsync_Domain_Dropbox_DropboxSync');
     $dropboxSync->syncAll();
     return true;
 }
 /**
  * @return void
  */
 protected function initializeConcreteConfigurationManager()
 {
     if (TYPO3_MODE === 'FE') {
         $this->concreteConfigurationManager = $this->objectManager->get('Tx_Extbase_Configuration_FrontendConfigurationManager');
     } else {
         $this->concreteConfigurationManager = $this->objectManager->get('Tx_Extbase_Configuration_BackendConfigurationManager');
     }
 }
Example #4
0
 /**
  * @return void
  */
 public function __wakeup()
 {
     $this->objectManager = t3lib_div::makeInstance('Tx_Extbase_Object_ObjectManager');
     $this->persistenceManager = $this->objectManager->get('Tx_Extbase_Persistence_ManagerInterface');
     $this->dataMapper = $this->objectManager->get('Tx_Extbase_Persistence_Mapper_DataMapper');
     $this->qomFactory = $this->objectManager->get('Tx_Extbase_Persistence_QOM_QueryObjectModelFactory');
 }
Example #5
0
 /**
  * Commits new objects and changes to objects in the current persistence
  * session into the backend
  *
  * @return void
  * @api
  */
 public function persistAll()
 {
     $aggregateRootObjects = new Tx_Extbase_Persistence_ObjectStorage();
     $removedObjects = new Tx_Extbase_Persistence_ObjectStorage();
     // fetch and inspect objects from all known repositories
     foreach ($this->repositoryClassNames as $repositoryClassName) {
         $repository = $this->objectManager->get($repositoryClassName);
         $aggregateRootObjects->addAll($repository->getAddedObjects());
         $removedObjects->addAll($repository->getRemovedObjects());
     }
     foreach ($this->session->getReconstitutedObjects() as $reconstitutedObject) {
         if (class_exists(str_replace('_Model_', '_Repository_', get_class($reconstitutedObject)) . 'Repository')) {
             $aggregateRootObjects->attach($reconstitutedObject);
         }
     }
     // hand in only aggregate roots, leaving handling of subobjects to
     // the underlying storage layer
     $this->backend->setAggregateRootObjects($aggregateRootObjects);
     $this->backend->setDeletedObjects($removedObjects);
     $this->backend->commit();
     // this needs to unregister more than just those, as at least some of
     // the subobjects are supposed to go away as well...
     // OTOH those do no harm, changes to the unused ones should not happen,
     // so all they do is eat some memory.
     foreach ($removedObjects as $removedObject) {
         $this->session->unregisterReconstitutedObject($removedObject);
     }
 }
Example #6
0
 /**
  * Runs the the Extbase Framework by resolving an appropriate Request Handler and passing control to it.
  * If the Framework is not initialized yet, it will be initialized.
  *
  * @param string $content The content
  * @param array $configuration The TS configuration array
  * @return string $content The processed content
  * @api
  */
 public function run($content, $configuration)
 {
     //var_dump(Tx_Extbase_Utility_Extension::createAutoloadRegistryForExtension('extbase', t3lib_extMgm::extPath('extbase'), array(
     //	'tx_extbase_basetestcase' => '$extensionClassesPath . \'../Tests/BaseTestCase.php\'',
     //	'tx_extbase_tests_unit_basetestcase' => '$extensionClassesPath . \'../Tests/Unit/BaseTestCase.php\'',
     //)));
     //die("autoload registry");
     $this->initialize($configuration);
     $requestHandlerResolver = $this->objectManager->get('Tx_Extbase_MVC_RequestHandlerResolver');
     $requestHandler = $requestHandlerResolver->resolveRequestHandler();
     $response = $requestHandler->handleRequest();
     // If response is NULL after handling the request we need to stop
     // This happens for instance, when a USER object was converted to a USER_INT
     // @see Tx_Extbase_MVC_Web_FrontendRequestHandler::handleRequest()
     if ($response === NULL) {
         $this->reflectionService->shutdown();
         return;
     }
     if (count($response->getAdditionalHeaderData()) > 0) {
         $GLOBALS['TSFE']->additionalHeaderData[] = implode(chr(10), $response->getAdditionalHeaderData());
     }
     $response->sendHeaders();
     $content = $response->getContent();
     $this->resetSingletons();
     return $content;
 }
 /**
  * Build parser configuration
  *
  * @return Tx_Fluid_Core_Parser_Configuration
  * @author Karsten Dambekalns <*****@*****.**>
  */
 protected function buildParserConfiguration()
 {
     $parserConfiguration = $this->objectManager->create('Tx_Fluid_Core_Parser_Configuration');
     if ($this->controllerContext->getRequest()->getFormat() === 'html') {
         $parserConfiguration->addInterceptor($this->objectManager->get('Tx_Fluid_Core_Parser_Interceptor_Escape'));
     }
     return $parserConfiguration;
 }
Example #8
0
 public function getOpenedPercentage()
 {
     $emailRepository = $this->objectManager->get('Tx_Newsletter_Domain_Repository_EmailRepository');
     $emailCount = $emailRepository->getCount($this->newsletter);
     if ($emailCount == 0) {
         return 0;
     }
     return round($this->getOpenedCount() * 100 / $emailCount, 2);
 }
 /**
  * Validation of given Params
  *
  * @param Tx_WoehrlSeminare_Domain_Model_Subscriber $newSubscriber
  * @return bool
  */
 public function isValid($newSubscriber)
 {
     if (strlen($newSubscriber->getName()) < 3) {
         $error = $this->objectManager->get('Tx_Extbase_Error_Error', 'val_name', 1000);
         $this->result->forProperty('name')->addError($error);
         // usually $this->addError is enough but this doesn't set the CSS errorClass in the form-viewhelper :-(
         //			$this->addError('val_name', 1000);
         $this->isValid = FALSE;
     }
     if (!t3lib_div::validEmail($newSubscriber->getEmail())) {
         $error = $this->objectManager->get('Tx_Extbase_Error_Error', 'val_email', 1100);
         $this->result->forProperty('email')->addError($error);
         //			$this->addError('val_email', 1100);
         $this->isValid = FALSE;
     }
     if (strlen($newSubscriber->getCustomerid()) > 0 && filter_var($newSubscriber->getCustomerid(), FILTER_VALIDATE_INT) === FALSE) {
         $error = $this->objectManager->get('Tx_Extbase_Error_Error', 'val_customerid', 1110);
         $this->result->forProperty('customerid')->addError($error);
         //			$this->addError('val_customerid', 1110);
         $this->isValid = FALSE;
     }
     if (strlen($newSubscriber->getNumber()) == 0 || filter_var($newSubscriber->getNumber(), FILTER_VALIDATE_INT) === FALSE || $newSubscriber->getNumber() < 1) {
         $error = $this->objectManager->get('Tx_Extbase_Error_Error', 'val_number', 1120);
         $this->result->forProperty('number')->addError($error);
         //			$this->addError('val_number', 1120);
         $this->isValid = FALSE;
     } else {
         $event = $newSubscriber->getEvent();
         // limit reached already --> overbooked
         if ($this->subscriberRepository->countAllByEvent($event) + $newSubscriber->getNumber() > $event->getMaxSubscriber()) {
             $error = $this->objectManager->get('Tx_Extbase_Error_Error', 'val_number', 1130);
             $this->result->forProperty('number')->addError($error);
             //			    $this->addError('val_number', 1130);
             $this->isValid = FALSE;
         }
     }
     if ($newSubscriber->getEditcode() != $this->getSessionData('editcode')) {
         $error = $this->objectManager->get('Tx_Extbase_Error_Error', 'val_editcode', 1140);
         $this->result->forProperty('editcode')->addError($error);
         //			$this->addError('val_editcode', 1140);
         $this->isValid = FALSE;
     }
     return $this->isValid;
 }
Example #10
0
 /**
  * Check client browser
  *
  * @param array $code Not used
  * @return boolean
  */
 public function pack($code)
 {
     $encoding = 62;
     // see value in Tx_Nbogallery_Utility_JavascriptPacker
     $fastDecode = FALSE;
     $specialChars = FALSE;
     $packer = $this->objectManager->get('Tx_Nbogallery_Utility_JavascriptPacker', $encoding, $fastDecode, $specialChars);
     $packed = $packer->pack();
     return (string) $packed;
 }
Example #11
0
 /**
  * Create and set a validator chain
  *
  * @param array Object names of the validators
  * @return Tx_Extbase_MVC_Controller_Argument Returns $this (used for fluent interface)
  * @api
  */
 public function setNewValidatorConjunction(array $objectNames)
 {
     if ($this->validator === NULL) {
         $this->validator = $this->objectManager->create('Tx_Extbase_Validation_Validator_ConjunctionValidator');
     }
     foreach ($objectNames as $objectName) {
         if (!class_exists($objectName)) {
             $objectName = 'Tx_Extbase_Validation_Validator_' . $objectName;
         }
         $this->validator->addValidator($this->objectManager->get($objectName));
     }
     return $this;
 }
Example #12
0
 /**
  * Constructs a new Repository
  *
  * @param Tx_Extbase_Object_ObjectManagerInterface $objectManager
  */
 public function __construct(Tx_Extbase_Object_ObjectManagerInterface $objectManager = NULL)
 {
     $this->addedObjects = new Tx_Extbase_Persistence_ObjectStorage();
     $this->removedObjects = new Tx_Extbase_Persistence_ObjectStorage();
     $this->objectType = str_replace(array('_Repository_', 'Repository'), array('_Model_', ''), $this->getRepositoryClassName());
     if ($objectManager === NULL) {
         // Legacy creation, in case the object manager is NOT injected
         // If ObjectManager IS there, then all properties are automatically injected
         $this->objectManager = t3lib_div::makeInstance('Tx_Extbase_Object_ObjectManager');
         $this->injectIdentityMap($this->objectManager->get('Tx_Extbase_Persistence_IdentityMap'));
         $this->injectQueryFactory($this->objectManager->get('Tx_Extbase_Persistence_QueryFactory'));
         $this->injectPersistenceManager($this->objectManager->get('Tx_Extbase_Persistence_Manager'));
     } else {
         $this->objectManager = $objectManager;
     }
 }
 protected function createEventManager()
 {
     $metadataService = new Tx_Doctrine2_Mapping_TYPO3MetadataService();
     $metadataService->injectReflectionService($this->reflectionService);
     $this->dataMapFactory->injectReflectionService($this->reflectionService);
     $metadataService->injectDataMapFactory($this->dataMapFactory);
     $metadataListener = new Tx_Doctrine2_Mapping_TYPO3TCAMetadataListener();
     $metadataListener->injectMetadataService($metadataService);
     $evm = new \Doctrine\Common\EventManager();
     $evm->addEventSubscriber($metadataListener);
     if ($this->objectManager) {
         $storagePidListener = $this->objectManager->get('Tx_Doctrine2_Persistence_StoragePidListener');
         $evm->addEventSubscriber($storagePidListener);
     }
     $this->configureEventManager($evm);
     return $evm;
 }
 /**
  * Analyzes the raw request and tries to find a request handler which can handle
  * it. If none is found, an exception is thrown.
  *
  * @return Tx_Extbase_MVC_RequestHandler A request handler
  * @throws Tx_Extbase_MVC_Exception
  */
 public function resolveRequestHandler()
 {
     $availableRequestHandlerClassNames = $this->getRegisteredRequestHandlerClassNames();
     $suitableRequestHandlers = array();
     foreach ($availableRequestHandlerClassNames as $requestHandlerClassName) {
         $requestHandler = $this->objectManager->get($requestHandlerClassName);
         if ($requestHandler->canHandleRequest()) {
             $priority = $requestHandler->getPriority();
             if (isset($suitableRequestHandlers[$priority])) {
                 throw new Tx_Extbase_MVC_Exception('More than one request handler with the same priority can handle the request, but only one handler may be active at a time!', 1176475350);
             }
             $suitableRequestHandlers[$priority] = $requestHandler;
         }
     }
     if (count($suitableRequestHandlers) === 0) {
         throw new Tx_Extbase_MVC_Exception('No suitable request handler found.', 1205414233);
     }
     ksort($suitableRequestHandlers);
     return array_pop($suitableRequestHandlers);
 }
Example #15
0
 /**
  * Copies Domain Object as clone
  *
  * @param Tx_Extbase_DomainObject_DomainObjectInterface $value
  * @return Tx_Extbase_DomainObject_DomainObjectInterface
  * @api
  */
 protected function copyAsClone($value)
 {
     if ($value instanceof Tx_Extbase_Persistence_ObjectStorage) {
         // objectstorage; copy storage and copy items, return new storage
         $newStorage = $this->objectManager->get('Tx_Extbase_Persistence_ObjectStorage');
         foreach ($value as $item) {
             $newItem = $this->copy($item);
             $newStorage->attach($newItem);
         }
         return $newStorage;
     } elseif ($value instanceof Tx_Extbase_DomainObject_DomainObjectInterface) {
         // DomainObject; copy and return
         /** @var $value Tx_Extbase_DomainObject_DomainObjectInterface */
         return $this->copy($value);
     } elseif (is_object($value)) {
         // fallback case for class copying - value objects and such
         return clone $value;
     } else {
         // value is probably a string
         return $value;
     }
 }
 /**
  * Builds a base validator conjunction for the given data type.
  *
  * The base validation rules are those which were declared directly in a class (typically
  * a model) through some @validate annotations on properties.
  *
  * Additionally, if a custom validator was defined for the class in question, it will be added
  * to the end of the conjunction. A custom validator is found if it follows the naming convention
  * "Replace '\Model\' by '\Validator\' and append "Validator".
  *
  * Example: $dataType is F3\Foo\Domain\Model\Quux, then the Validator will be found if it has the
  * name F3\Foo\Domain\Validator\QuuxValidator
  *
  * @param string $dataType The data type to build the validation conjunction for. Needs to be the fully qualified object name.
  * @return Tx_Extbase_Validation_Validator_ConjunctionValidator The validator conjunction or NULL
  */
 protected function buildBaseValidatorConjunction($dataType)
 {
     $validatorConjunction = $this->objectManager->get('Tx_Extbase_Validation_Validator_ConjunctionValidator');
     // Model based validator
     if (strstr($dataType, '_') !== FALSE && class_exists($dataType)) {
         $validatorCount = 0;
         $objectValidator = $this->createValidator('GenericObject');
         foreach ($this->reflectionService->getClassPropertyNames($dataType) as $classPropertyName) {
             $classPropertyTagsValues = $this->reflectionService->getPropertyTagsValues($dataType, $classPropertyName);
             if (!isset($classPropertyTagsValues['validate'])) {
                 continue;
             }
             foreach ($classPropertyTagsValues['validate'] as $validateValue) {
                 $parsedAnnotation = $this->parseValidatorAnnotation($validateValue);
                 foreach ($parsedAnnotation['validators'] as $validatorConfiguration) {
                     $newValidator = $this->createValidator($validatorConfiguration['validatorName'], $validatorConfiguration['validatorOptions']);
                     if ($newValidator === NULL) {
                         throw new Tx_Extbase_Validation_Exception_NoSuchValidator('Invalid validate annotation in ' . $dataType . '::' . $classPropertyName . ': Could not resolve class name for  validator "' . $validatorConfiguration['validatorName'] . '".', 1241098027);
                     }
                     $objectValidator->addPropertyValidator($classPropertyName, $newValidator);
                     $validatorCount++;
                 }
             }
         }
         if ($validatorCount > 0) {
             $validatorConjunction->addValidator($objectValidator);
         }
     }
     // Custom validator for the class
     $possibleValidatorClassName = str_replace('_Model_', '_Validator_', $dataType) . 'Validator';
     $customValidator = $this->createValidator($possibleValidatorClassName);
     if ($customValidator !== NULL) {
         $validatorConjunction->addValidator($customValidator);
     }
     return $validatorConjunction;
 }
 /**
  * @return void
  */
 protected function tearDownFramework()
 {
     $this->objectManager->get('Tx_Extbase_Persistence_Manager')->persistAll();
     $this->objectManager->get('Tx_Extbase_Reflection_Service')->shutdown();
 }