Ejemplo n.º 1
0
 /**
  * @return void
  */
 protected function injectDependencies()
 {
     $this->mockConfigurationManager->expects($this->any())->method('getConfiguration')->will($this->returnValue($this->configuration));
     $this->requestBuilder->injectConfigurationManager($this->mockConfigurationManager);
     $this->mockObjectManager->expects($this->any())->method('create')->with('Tx_Extbase_MVC_Web_Request')->will($this->returnValue($this->mockRequest));
     $this->requestBuilder->injectObjectManager($this->mockObjectManager);
 }
Ejemplo n.º 2
0
 /**
  * @test
  */
 public function executeReturnsQueryResultInstanceAndInjectsItself()
 {
     $queryResult = $this->getMock('Tx_Extbase_Persistence_QueryResult', array(), array(), '', FALSE);
     $this->objectManager->expects($this->once())->method('create')->with('Tx_Extbase_Persistence_QueryResultInterface', $this->query)->will($this->returnValue($queryResult));
     $actualResult = $this->query->execute();
     $this->assertSame($queryResult, $actualResult);
 }
Ejemplo n.º 3
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);
 }
Ejemplo n.º 4
0
 /**
  * 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');
     }
 }
Ejemplo n.º 6
0
 /**
  * Creates a query object working on the given class name
  *
  * @param string $className The class name
  * @return Tx_Extbase_Persistence_QueryInterface
  */
 public function create($className)
 {
     $query = $this->objectManager->create('Tx_Extbase_Persistence_QueryInterface', $className);
     $querySettings = $this->objectManager->create('Tx_Extbase_Persistence_Typo3QuerySettings');
     $frameworkConfiguration = $this->configurationManager->getConfiguration(Tx_Extbase_Configuration_ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
     $querySettings->setStoragePageIds(t3lib_div::intExplode(',', $frameworkConfiguration['persistence']['storagePid']));
     $query->setQuerySettings($querySettings);
     return $query;
 }
	/**
	 * Parses variables again
	 *
	 * @param	array		Variables and Markers array
	 * @param	array		Variables and Labels array
	 * @param	string		"web" or "mail"
	 * @return 	string		Changed string
	 */
	public function render($variablesMarkers = array(), $variablesLabels = array(), $type = 'web') {
		$parseObject = $this->objectManager->create('Tx_Fluid_View_StandaloneView');
		$parseObject->setTemplateSource($this->renderChildren());
		$parseObject->assignMultiple($this->div->htmlspecialcharsOnArray($variablesMarkers));

		$powermailAll = $this->div->powermailAll($variablesLabels, $this->configurationManager, $this->objectManager, $type, $this->settings);
		$parseObject->assign('powermail_all', $powermailAll);

		return html_entity_decode($parseObject->render());
	}
 /**
  * @return Tx_Doctrine2_Query
  */
 public function create($className)
 {
     $query = new Tx_Doctrine2_Query($className);
     $query->injectEntityManager($this->manager->getEntityManager());
     if (!$this->objectManager || !$this->configurationManager) {
         return $query;
     }
     $querySettings = $this->objectManager->create('Tx_Extbase_Persistence_QuerySettingsInterface');
     $frameworkConfiguration = $this->configurationManager->getConfiguration(Tx_Extbase_Configuration_ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
     $querySettings->setStoragePageIds(t3lib_div::intExplode(',', $frameworkConfiguration['persistence']['storagePid']));
     $query->setQuerySettings($querySettings);
     return $query;
 }
	/**
	 * ViewHelper combines Raw and RemoveXss Methods
	 *
	 * @return string
	 */
	public function render() {
		$string = $this->renderChildren();

		// parse string
		$parseObject = $this->objectManager->create('Tx_Fluid_View_StandaloneView');
		$parseObject->setTemplateSource($string);
		$string = $parseObject->render();

		// remove XSS
		$string = t3lib_div::removeXSS($string);

		return $string;
	}
 /**
  * @author Sebastian Kurfürst <*****@*****.**>
  * @author Bastian Waidelich <*****@*****.**>
  */
 public function setUp()
 {
     $this->serverBackup = $_SERVER;
     $this->getBackup = $_GET;
     $this->postBackup = $_POST;
     $this->widgetRequestBuilder = $this->getAccessibleMock('Tx_Fluid_Core_Widget_WidgetRequestBuilder', array('setArgumentsFromRawRequestData'));
     $this->mockWidgetRequest = $this->getMock('Tx_Fluid_Core_Widget_WidgetRequest');
     $this->mockObjectManager = $this->getMock('Tx_Extbase_Object_ObjectManagerInterface');
     $this->mockObjectManager->expects($this->once())->method('create')->with('Tx_Fluid_Core_Widget_WidgetRequest')->will($this->returnValue($this->mockWidgetRequest));
     $this->widgetRequestBuilder->_set('objectManager', $this->mockObjectManager);
     $this->mockWidgetContext = $this->getMock('Tx_Fluid_Core_Widget_WidgetContext');
     $this->mockAjaxWidgetContextHolder = $this->getMock('Tx_Fluid_Core_Widget_AjaxWidgetContextHolder');
     $this->widgetRequestBuilder->injectAjaxWidgetContextHolder($this->mockAjaxWidgetContextHolder);
     $this->mockAjaxWidgetContextHolder->expects($this->once())->method('get')->will($this->returnValue($this->mockWidgetContext));
 }
Ejemplo n.º 11
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');
 }
Ejemplo n.º 12
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;
 }
Ejemplo n.º 13
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);
     }
 }
 /**
  * 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;
 }
Ejemplo n.º 15
0
 /**
  * Creates, adds and returns a new controller argument to this composite object.
  * If an argument with the same name exists already, it will be replaced by the
  * new argument object.
  *
  * @param string $name Name of the argument
  * @param string $dataType Name of one of the built-in data types
  * @param boolean $isRequired TRUE if this argument should be marked as required
  * @param mixed $defaultValue Default value of the argument. Only makes sense if $isRequired==FALSE
  * @return Tx_Extbase_MVC_Controller_Argument The new argument
  */
 public function addNewArgument($name, $dataType = 'Text', $isRequired = FALSE, $defaultValue = NULL)
 {
     $argument = $this->objectManager->create('Tx_Extbase_MVC_Controller_Argument', $name, $dataType);
     $argument->setRequired($isRequired);
     $argument->setDefaultValue($defaultValue);
     $this->addArgument($argument);
     return $argument;
 }
Ejemplo n.º 16
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);
 }
Ejemplo n.º 17
0
 /**
  * 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;
 }
Ejemplo n.º 18
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;
 }
Ejemplo n.º 19
0
 /**
  * Adds a ViewHelper node using the EscapeViewHelper to the given node.
  * If "escapingInterceptorEnabled" in the ViewHelper is FALSE, will disable itself inside the ViewHelpers body.
  *
  * @param Tx_Fluid_Core_Parser_SyntaxTree_NodeInterface $node
  * @param integer $interceptorPosition One of the INTERCEPT_* constants for the current interception point
  * @return Tx_Fluid_Core_Parser_SyntaxTree_NodeInterface
  * @author Karsten Dambekalns <*****@*****.**>
  * @author Sebastian Kurfürst <*****@*****.**>
  */
 public function process(Tx_Fluid_Core_Parser_SyntaxTree_NodeInterface $node, $interceptorPosition)
 {
     if ($interceptorPosition === Tx_Fluid_Core_Parser_InterceptorInterface::INTERCEPT_OPENING_VIEWHELPER) {
         if (!$node->getUninitializedViewHelper()->isEscapingInterceptorEnabled()) {
             $this->interceptorEnabled = FALSE;
             $this->viewHelperNodesWhichDisableTheInterceptor[] = $node;
         }
     } elseif ($interceptorPosition === Tx_Fluid_Core_Parser_InterceptorInterface::INTERCEPT_CLOSING_VIEWHELPER) {
         if (end($this->viewHelperNodesWhichDisableTheInterceptor) === $node) {
             array_pop($this->viewHelperNodesWhichDisableTheInterceptor);
             if (count($this->viewHelperNodesWhichDisableTheInterceptor) === 0) {
                 $this->interceptorEnabled = TRUE;
             }
         }
     } elseif ($this->interceptorEnabled && $node instanceof Tx_Fluid_Core_Parser_SyntaxTree_ObjectAccessorNode) {
         $node = $this->objectManager->create('Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode', $this->objectManager->create('Tx_Fluid_ViewHelpers_EscapeViewHelper'), array('value' => $node));
     }
     return $node;
 }
Ejemplo n.º 20
0
 /**
  * @test
  * @author Sebastian Kurfürst <*****@*****.**>
  */
 public function multipleEvaluateCallsShareTheSameViewHelperInstance()
 {
     $mockViewHelper = $this->getMock('Tx_Fluid_Core_ViewHelper_AbstractViewHelper', array('render', 'validateArguments', 'prepareArguments', 'setViewHelperVariableContainer'));
     $mockViewHelper->expects($this->any())->method('render')->will($this->returnValue('String'));
     $viewHelperNode = new Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode($mockViewHelper, array());
     $mockViewHelperArguments = $this->getMock('Tx_Fluid_Core_ViewHelper_Arguments', array(), array(), '', FALSE);
     $this->mockObjectManager->expects($this->at(0))->method('create')->with('Tx_Fluid_Core_ViewHelper_Arguments')->will($this->returnValue($mockViewHelperArguments));
     $this->mockObjectManager->expects($this->at(1))->method('create')->with('Tx_Fluid_Core_ViewHelper_Arguments')->will($this->returnValue($mockViewHelperArguments));
     $viewHelperNode->evaluate($this->renderingContext);
     $viewHelperNode->evaluate($this->renderingContext);
 }
Ejemplo n.º 21
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;
 }
Ejemplo n.º 22
0
 /**
  * Maps arguments delivered by the request object to the local controller arguments.
  *
  * @return void
  */
 protected function mapRequestArgumentsToControllerArguments()
 {
     $optionalPropertyNames = array();
     $allPropertyNames = $this->arguments->getArgumentNames();
     foreach ($allPropertyNames as $propertyName) {
         if ($this->arguments[$propertyName]->isRequired() === FALSE) {
             $optionalPropertyNames[] = $propertyName;
         }
     }
     $validator = $this->objectManager->create('Tx_Extbase_MVC_Controller_ArgumentsValidator');
     $this->propertyMapper->mapAndValidate($allPropertyNames, $this->request->getArguments(), $this->arguments, $optionalPropertyNames, $validator);
     $this->argumentsMappingResults = $this->propertyMapper->getMappingResults();
 }
Ejemplo n.º 23
0
 /**
  * Sends the response
  *
  * @param array $results The collected results from the transaction requests
  * @param Tx_Newsletter_MVC_ExtDirect_Request $extDirectRequest
  * @return void
  * @author Robert Lemke <*****@*****.**>
  */
 protected function sendResponse(array $results, Tx_Newsletter_MVC_ExtDirect_Request $extDirectRequest)
 {
     $response = $this->objectManager->create('Tx_Extbase_MVC_Web_Response');
     $jsonResponse = json_encode(count($results) === 1 ? $results[0] : $results);
     if ($extDirectRequest->isFormPost() && $extDirectRequest->isFileUpload()) {
         $response->setHeader('Content-Type', 'text/html');
         $response->setContent('<html><body><textarea>' . $jsonResponse . '</textarea></body></html>');
     } else {
         $response->setHeader('Content-Type', 'application/json');
         $response->setContent($jsonResponse);
     }
     return $response;
 }
Ejemplo n.º 24
0
 /**
  * Returns a sample blog populated with generic data
  * It is also an example how to handle objects and repositories in general
  *
  * @param integer $blogNumber
  * @return Tx_BlogExample_Domain_Model_Blog
  */
 public function createBlog($blogNumber = 1)
 {
     // initialize blog
     $blog = $this->objectManager->create('Tx_BlogExample_Domain_Model_Blog');
     $blog->setTitle('Blog #' . $blogNumber);
     $blog->setDescription('A blog about TYPO3 extension development.');
     // create author
     $author = $this->objectManager->create('Tx_BlogExample_Domain_Model_Person', 'Stephen', 'Smith', '*****@*****.**');
     // create administrator
     $administrator = $this->objectManager->create('Tx_BlogExample_Domain_Model_Administrator');
     $administrator->setName('John Doe');
     $administrator->setEmail('*****@*****.**');
     $blog->setAdministrator($administrator);
     // create sample posts
     for ($postNumber = 1; $postNumber < 6; $postNumber++) {
         // create post
         $post = $this->objectManager->create('Tx_BlogExample_Domain_Model_Post');
         $post->setTitle('The ' . $postNumber . '. post of blog #' . $blogNumber);
         $post->setAuthor($author);
         $post->setContent('Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.');
         // create comments
         $comment = $this->objectManager->create('Tx_BlogExample_Domain_Model_Comment');
         $comment->setDate(new DateTime());
         $comment->setAuthor('Peter Pan');
         $comment->setEmail('*****@*****.**');
         $comment->setContent('Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.');
         $post->addComment($comment);
         $comment = $this->objectManager->create('Tx_BlogExample_Domain_Model_Comment');
         $comment->setDate(new DateTime('2009-03-19 23:44'));
         $comment->setAuthor('John Smith');
         $comment->setEmail('*****@*****.**');
         $comment->setContent('Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.');
         $post->addComment($comment);
         // create some random tags
         if (rand(0, 1) > 0) {
             $tag = $this->objectManager->create('Tx_BlogExample_Domain_Model_Tag', 'MVC');
             $post->addTag($tag);
         }
         if (rand(0, 1) > 0) {
             $tag = $this->objectManager->create('Tx_BlogExample_Domain_Model_Tag', 'Domain Driven Design');
             $post->addTag($tag);
         }
         if (rand(0, 1) > 0) {
             $tag = $this->objectManager->create('Tx_BlogExample_Domain_Model_Tag', 'TYPO3');
             $post->addTag($tag);
         }
         // add the post to the current blog
         $blog->addPost($post);
         $post->setBlog($blog);
     }
     return $blog;
 }
 /**
  * Initiate a sub request to $this->controller. Make sure to fill $this->controller
  * via Dependency Injection.
  *
  * @return Tx_Extbase_MVC_Response the response of this request.
  * @api
  * @author Sebastian Kurfürst <*****@*****.**>
  */
 protected function initiateSubRequest()
 {
     if (!$this->controller instanceof Tx_Fluid_Core_Widget_AbstractWidgetController) {
         if (isset($this->controller)) {
             throw new Tx_Fluid_Core_Widget_Exception_MissingControllerException('initiateSubRequest() can not be called if there is no valid controller extending Tx_Fluid_Core_Widget_AbstractWidgetController. Got "' . get_class($this->controller) . '" in class "' . get_class($this) . '".', 1289422564);
         }
         throw new Tx_Fluid_Core_Widget_Exception_MissingControllerException('initiateSubRequest() can not be called if there is no controller inside $this->controller. Make sure to add a corresponding injectController method to your WidgetViewHelper class "' . get_class($this) . '".', 1284401632);
     }
     $subRequest = $this->objectManager->create('Tx_Fluid_Core_Widget_WidgetRequest');
     $subRequest->setWidgetContext($this->widgetContext);
     $this->passArgumentsToSubRequest($subRequest);
     $subResponse = $this->objectManager->create('Tx_Extbase_MVC_Web_Response');
     $this->controller->processRequest($subRequest, $subResponse);
     return $subResponse;
 }
Ejemplo n.º 26
0
 /**
  * Builds a Json Ext Direct request by reading the transaction data from
  * standard input.
  *
  * @return Tx_Newsletter_MVC_ExtDirect_Request The Ext Direct request object
  * @throws Exception
  * @author Christopher Hlubek <*****@*****.**>
  * @author Robert Lemke <*****@*****.**>
  */
 protected function buildJsonRequest()
 {
     $transactionDatas = file_get_contents("php://input");
     if (($transactionDatas = json_decode($transactionDatas)) === NULL) {
         throw new Exception('The request is not a valid Ext Direct request', 1268490738);
     }
     if (!is_array($transactionDatas)) {
         $transactionDatas = array($transactionDatas);
     }
     $request = $this->objectManager->create('Tx_Newsletter_MVC_ExtDirect_Request');
     foreach ($transactionDatas as $transactionData) {
         $request->createAndAddTransaction($transactionData->action, $transactionData->method, is_array($transactionData->data) ? $transactionData->data : array(), $transactionData->tid);
     }
     return $request;
 }
Ejemplo n.º 27
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;
 }
Ejemplo n.º 29
0
 /**
  * Fetches a collection of objects related to a property of a parent object
  *
  * @param Tx_Extbase_DomainObject_DomainObjectInterface $parentObject The object instance this proxy is part of
  * @param string $propertyName The name of the proxied property in it's parent
  * @param mixed $fieldValue The raw field value.
  * @param bool $enableLazyLoading A flag indication if the related objects should be lazy loaded
  * @param bool $performLanguageOverlay A flag indication if the related objects should be localized
  * @return Tx_Extbase_Persistence_LazyObjectStorage|Tx_Extbase_Persistence_QueryResultInterface The result
  */
 public function fetchRelated(Tx_Extbase_DomainObject_DomainObjectInterface $parentObject, $propertyName, $fieldValue = '', $enableLazyLoading = TRUE)
 {
     $columnMap = $this->getDataMap(get_class($parentObject))->getColumnMap($propertyName);
     $propertyMetaData = $this->reflectionService->getClassSchema(get_class($parentObject))->getProperty($propertyName);
     if ($enableLazyLoading === TRUE && $propertyMetaData['lazy']) {
         if ($propertyMetaData['type'] === 'Tx_Extbase_Persistence_ObjectStorage') {
             $result = $this->objectManager->create('Tx_Extbase_Persistence_LazyObjectStorage', $parentObject, $propertyName, $fieldValue);
         } else {
             if (empty($fieldValue)) {
                 $result = NULL;
             } else {
                 $result = $this->objectManager->create('Tx_Extbase_Persistence_LazyLoadingProxy', $parentObject, $propertyName, $fieldValue);
             }
         }
     } else {
         $result = $this->fetchRelatedEager($parentObject, $propertyName, $fieldValue);
     }
     return $result;
 }
 /**
  * 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);
 }