本文整理汇总了PHP中TYPO3\CMS\Extbase\Object\ObjectManager::create方法的典型用法代码示例。如果您正苦于以下问题:PHP ObjectManager::create方法的具体用法?PHP ObjectManager::create怎么用?PHP ObjectManager::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Extbase\Object\ObjectManager
的用法示例。
在下文中一共展示了ObjectManager::create方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executeBehaviors
/**
* @param array $behaviors
* @param $object
* @param $controllerContext
* @param $default
* @param array $extraConf
* @return bool|object
*/
public function executeBehaviors(array $behaviors, $object, $controllerContext, $default, $extraConf = array())
{
$behaviorResponse = false;
foreach ($behaviors as $behaviorClassName => $enabled) {
if (is_array($enabled) && $enabled['_typoScriptNodeValue'] == true || !is_array($enabled) && $enabled == true) {
if (is_array($enabled)) {
$conf = $enabled;
} else {
$conf = array();
}
$conf = array_merge_recursive($conf, $extraConf);
$behavior = $this->objectManager->create($behaviorClassName);
$behavior->setControllerContext($controllerContext);
$result = $behavior->execute($object, $conf);
if ($result) {
$behaviorResponse = $result;
}
}
}
if ($behaviorResponse == false) {
$behaviorResponse = $this->objectManager->create('CIC\\Cicregister\\Behaviors\\Response\\RenderAction');
$behaviorResponse->setValue($default);
}
return $behaviorResponse;
}
示例2: execute
/**
* @param \CIC\Cicregister\Domain\Model\FrontendUser $frontendUser
* @param array $conf
* @return string
*/
public function execute(\CIC\Cicregister\Domain\Model\FrontendUser $frontendUser, array $conf)
{
// This method generates a login hash, which gets validated in the authentication service.
// The login hash is part of a query string that the user is redirected to.
$hashValidator = $this->objectManager->get('CIC\\Cicregister\\Service\\HashValidator');
$loginHash = $hashValidator->generateShortLivedKey($frontendUser->getUid());
$uriBuilder = $this->controllerContext->getUriBuilder();
$returnUrl = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('return_url');
$uri = $uriBuilder->reset()->setTargetPageUid($conf['forwardPid'])->setLinkAccessRestrictedPages(true)->setNoCache(false)->setUseCacheHash(false)->setArguments(array('return_url' => $returnUrl, 'logintype' => 'login', 'pid' => $conf['feuserPid'], 'loginHash' => $loginHash))->uriFor($conf['forwardAction'], NULL, 'FrontendUser');
$response = $this->objectManager->create('CIC\\Cicregister\\Behaviors\\Response\\RedirectURI');
$response->setValue($uri);
return $response;
}
示例3: decorate
/**
* @param array $decorators a list of decorators
* @param $object the object to be decorated
*/
public function decorate(array $decorators, $object)
{
foreach ($decorators as $decoratorClassName => $enabled) {
if ($enabled == true || is_array($enabled) && $enabled['_typoScriptNodeValue'] == true) {
if (is_array($enabled)) {
$conf = $enabled;
} else {
$conf = array();
}
$decorator = $this->objectManager->create($decoratorClassName);
$decorator->decorate($object, $conf);
}
}
}
示例4: convertDependenciesToObjects
/**
* @param string $dependencies
* @return \SplObjectStorage
*/
public function convertDependenciesToObjects($dependencies)
{
$unserializedDependencies = unserialize($dependencies);
$dependenciesObject = new \SplObjectStorage();
foreach ($unserializedDependencies as $dependencyType => $dependencyValues) {
foreach ($dependencyValues as $dependency => $versions) {
if ($dependencyType && $dependency) {
$versionNumbers = \TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionsStringToVersionNumbers($versions);
$lowest = $versionNumbers[0];
if (count($versionNumbers) === 2) {
$highest = $versionNumbers[1];
} else {
$highest = '';
}
/** @var $dependencyObject \TYPO3\CMS\Extensionmanager\Domain\Model\Dependency */
$dependencyObject = $this->objectManager->create('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Dependency');
$dependencyObject->setType($dependencyType);
$dependencyObject->setIdentifier($dependency);
$dependencyObject->setLowestVersion($lowest);
$dependencyObject->setHighestVersion($highest);
$dependenciesObject->attach($dependencyObject);
unset($dependencyObject);
}
}
}
return $dependenciesObject;
}
示例5: createMapperObject
public function createMapperObject($extName)
{
$mapperName = '\\Nng\\Nnfesubmit\\Mapper\\' . \TYPO3\CMS\Core\Utility\GeneralUtility::underscoredToUpperCamelCase($extName) . 'Mapper';
if (class_exists($mapperName)) {
return $this->objectManager->create($mapperName);
}
return false;
}
示例6: execute
/**
* Function execute from the Scheduler
*
* @return boolean TRUE on successful execution, FALSE on error
*/
public function execute()
{
list($extensionName, $controllerName, $commandName) = explode(':', $this->commandIdentifier);
$objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
$this->injectObjectManager($objectManager);
$request = $this->objectManager->create('TYPO3\\CMS\\Extbase\\Mvc\\Cli\\Request');
$dispatcher = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Mvc\\Dispatcher');
$response = $this->objectManager->create('TYPO3\\CMS\\Extbase\\Mvc\\Cli\\Response');
try {
$upperCamelCaseExtensionName = \TYPO3\CMS\Core\Utility\GeneralUtility::underscoredToUpperCamelCase($extensionName);
$upperCamelCaseControllerName = \TYPO3\CMS\Core\Utility\GeneralUtility::underscoredToUpperCamelCase($controllerName);
// TODO build class name a different way now that we have namespaces
// see https://www.pivotaltracker.com/story/show/73980994
$controllerObjectName = sprintf('Tx_%s_Command_%sCommandController', $upperCamelCaseExtensionName, $upperCamelCaseControllerName);
$request->setControllerCommandName($commandName);
$request->setControllerObjectName($controllerObjectName);
$request->setArguments((array) $this->arguments);
$dispatcher->dispatch($request, $response);
return TRUE;
} catch (\Exception $e) {
\TYPO3\CMS\Core\Utility\GeneralUtility::sysLog($e->getMessage(), $extensionName, $e->getCode());
return FALSE;
}
}
示例7: createFile
public function createFile(array $sourceData, $propertyPath, $allowedTypes, $maxSize)
{
$this->messages = new \TYPO3\CMS\Extbase\Error\Result();
$this->propertyPath = $propertyPath;
$key = $propertyPath ? $propertyPath : '';
$this->settings = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS);
$uploadedFileData = $this->getUploadedFileData();
$this->handleUploadErrors($uploadedFileData);
if ($this->messages->hasErrors()) {
$this->fileRepository->clearHeld($key);
return $this->messages->getFirstError();
} else {
if (!$this->settings['file']['dontValidateType']) {
$this->validateType($uploadedFileData, $allowedTypes);
}
if (!$this->settings['file']['dontValidateName']) {
$this->validateName($uploadedFileData);
}
if (!$this->settings['file']['dontValidateSize']) {
$this->validateSize($uploadedFileData, $maxSize);
}
}
if ($this->messages->hasErrors()) {
$this->fileRepository->clearHeld($key);
return $this->messages->getFirstError();
} else {
// ok to make a file object
$pathInfo = pathinfo($uploadedFileData['tmp_name']);
$fileObject = $this->objectManager->create('CIC\\Cicbase\\Domain\\Model\\File');
$fileObject->setTitle($sourceData['title']);
// TODO: Set a default title if it's not provided.
$fileObject->setDescription($sourceData['description']);
$fileObject->setIsSaved(false);
$fileObject->setOwner($GLOBALS['TSFE']->fe_user->user['uid']);
$fileObject->setSize($uploadedFileData['size']);
$fileObject->setMimeType($uploadedFileData['type']);
$fileObject->setOriginalFilename($uploadedFileData['name']);
$fileObject->setPath($uploadedFileData['tmp_name']);
$fileObject->setFilename($pathInfo['filename']);
$fileObject->setCrdate(time());
$results = $this->fileRepository->hold($fileObject, $key);
return $results;
}
}