当前位置: 首页>>代码示例>>PHP>>正文


PHP Object\ObjectManager类代码示例

本文整理汇总了PHP中TYPO3\CMS\Extbase\Object\ObjectManager的典型用法代码示例。如果您正苦于以下问题:PHP ObjectManager类的具体用法?PHP ObjectManager怎么用?PHP ObjectManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ObjectManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setUp

 /**
  * Set up dependencies
  */
 public function setUp()
 {
     parent::setUp();
     $this->objectManager = GeneralUtility::makeInstance(ObjectManager::class);
     $this->queue = $this->objectManager->get(BeanstalkdQueue::class, self::QUEUE_NAME, []);
     /** @var Pheanstalk\Pheanstalk $client */
     $client = $this->queue->getClient();
     // flush queue:
     try {
         while (true) {
             $job = $client->peekDelayed(self::QUEUE_NAME);
             $client->delete($job);
         }
     } catch (\Exception $e) {
     }
     try {
         while (true) {
             $job = $client->peekBuried(self::QUEUE_NAME);
             $client->delete($job);
         }
     } catch (\Exception $e) {
     }
     try {
         while (true) {
             $job = $client->peekReady(self::QUEUE_NAME);
             $client->delete($job);
         }
     } catch (\Exception $e) {
     }
 }
开发者ID:r3h6,项目名称:TYPO3.EXT.jobqueue_beanstalkd,代码行数:33,代码来源:BeanstalkdQueueTest.php

示例2: setUp

 /**
  * Sets up this test suite.
  */
 public function setUp()
 {
     parent::setUp();
     $this->setUpBackendUserFromFixture(1);
     $this->importDataSet(ORIGINAL_ROOT . 'typo3conf/ext/linkhandler/Tests/Functional/Fixtures/base_structure.xml');
     $this->importDataSet(ORIGINAL_ROOT . 'typo3conf/ext/linkhandler/Tests/Functional/Fixtures/tx_news_domain_model_news.xml');
     /** @var \TYPO3\CMS\Lang\LanguageService $languageService */
     $languageService = $this->getMock('TYPO3\\CMS\\Lang\\LanguageService');
     $GLOBALS['LANG'] = $languageService;
     /** @var \TYPO3\CMS\Core\TimeTracker\TimeTracker $timeTracker */
     $timeTracker = $this->getMock('TYPO3\\CMS\\Core\\TimeTracker\\TimeTracker');
     $GLOBALS['TT'] = $timeTracker;
     /** @var \TYPO3\CMS\Frontend\Page\PageRepository $pageRepository */
     $pageRepository = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository');
     /** @var \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController $typoScriptFrontendController */
     $typoScriptFrontendController = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController', $GLOBALS['TYPO3_CONF_VARS'], 1, 0);
     $this->typoScriptFrontendController = $typoScriptFrontendController;
     $GLOBALS['TSFE'] = $typoScriptFrontendController;
     $typoScriptFrontendController->sys_page = $pageRepository;
     $typoScriptFrontendController->getPageAndRootline();
     $typoScriptFrontendController->initTemplate();
     $typoScriptFrontendController->getConfigArray();
     // This is needed for the configuration manager to load the correct TSconfig.
     $_GET['P'] = array('pid' => 1);
     /** @var \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $contentObjectRenderer */
     $contentObjectRenderer = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
     $contentObjectRenderer->start(array());
     $this->objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
     /** @var \TYPO3\CMS\Extbase\Configuration\ConfigurationManager $configurationManager */
     $configurationManager = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager');
     $configurationManager->setContentObject($contentObjectRenderer);
     $this->uriBuilder = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Routing\\UriBuilder');
 }
开发者ID:frans-beech-it,项目名称:linkhandler,代码行数:36,代码来源:UriBuilderTest.php

示例3: getCache

 /**
  * Get the static file cache
  *
  * @return FrontendInterface
  * @throws NoSuchCacheException
  */
 public static function getCache()
 {
     /** @var CacheManager $cacheManager */
     $objectManager = new ObjectManager();
     $cacheManager = $objectManager->get(CacheManager::class);
     return $cacheManager->getCache('static_file_cache');
 }
开发者ID:qbus-agentur,项目名称:nc_staticfilecache,代码行数:13,代码来源:CacheUtility.php

示例4: TYPO3Boot

 /**
  * TYPO3 boot
  *
  * @param \Behat\Behat\Context\Context $context
  * @param \Behat\Behat\Hook\Scope\ScenarioScope $scope
  */
 public function TYPO3Boot(&$context = NULL, &$scope = NULL)
 {
     if (!defined('ORIGINAL_ROOT')) {
         define('ORIGINAL_ROOT', strtr(getenv('TYPO3_PATH_WEB') ? getenv('TYPO3_PATH_WEB') . '/' : getcwd() . '/', '\\', '/'));
     }
     if (getenv('BEHAT_TYPO3_DOCROOT') && !defined('BEHAT_ROOT')) {
         define('BEHAT_ROOT', strtr(getenv('BEHAT_TYPO3_DOCROOT'), '\\', '/'));
     }
     $this->typo3BootstrapUtility = defined('BEHAT_ROOT') ? new Typo3BootstrapUtilityStatic() : new Typo3BootstrapUtilityDynamic();
     $this->typo3InstancePath = $this->typo3BootstrapUtility->setUp($scope->getFeature()->getFile(), $this->typo3CoreExtensionsToLoad, $this->typo3TestExtensionsToLoad, $this->typo3PathsToLinkInTestInstance, $this->typo3ConfigurationToUseInTestInstance, $this->typo3AdditionalFoldersToCreate);
     // import db
     if (count($this->typo3DatabaseToImport) > 0) {
         foreach ($this->typo3DatabaseToImport as $path) {
             $this->importDataSet($path);
         }
     }
     // setup fe
     if (count($this->typo3FrontendRootPage) > 0) {
         $this->setupFrontendRootPage($this->typo3FrontendRootPage['pageId'], $this->typo3FrontendRootPage['typoscript'], $this->typo3FrontendRootPage['typoscriptConstants']);
     }
     // rewrite mink parameter
     $this->typo3BootstrapUtility->rewriteMinkParameter($context);
     // preparing object manager
     $this->typo3ObjectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
     // preparing persistance manager
     $this->typo3PersistenceManager = $this->typo3ObjectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\PersistenceManager');
 }
开发者ID:heiko-hardt,项目名称:behat-typo3-extension,代码行数:33,代码来源:Typo3.php

示例5: setUp

 public function setUp()
 {
     parent::setUp();
     $this->objectManager = GeneralUtility::makeInstance(ObjectManager::class);
     $this->queue = $this->objectManager->get(DatabaseQueue::class, self::QUEUE_NAME, ['timeout' => 0]);
     $this->setUpBasicFrontendEnvironment();
 }
开发者ID:r3h6,项目名称:TYPO3.EXT.jobqueue_database,代码行数:7,代码来源:DatabaseQueueTest.php

示例6: render

 /**
  * Render the different elements and collect the single lines.
  * After the rendering the lines will be imploded. Notice:
  * All methods after this are CType rendering helper
  *
  * @param string $content
  * @param array  $conf
  *
  * @return array
  */
 public function render($content, $conf)
 {
     $lines = array();
     $this->conf = $conf;
     $CType = (string) $this->cObj->data['CType'];
     if (isset($this->conf['forceCType']) && trim($this->conf['forceCType']) !== '') {
         $CType = trim($this->conf['forceCType']);
     }
     $renderer = array('html' => 'FRUIT\\Ink\\Rendering\\Html', 'header' => 'FRUIT\\Ink\\Rendering\\Header', 'table' => 'FRUIT\\Ink\\Rendering\\Table', 'menu' => 'FRUIT\\Ink\\Rendering\\Menu', 'text' => 'FRUIT\\Ink\\Rendering\\Text', 'image' => 'FRUIT\\Ink\\Rendering\\Image', 'textpic' => 'FRUIT\\Ink\\Rendering\\TextPicture', 'templavoila_pi1' => 'FRUIT\\Ink\\Rendering\\Templavoila', 'list' => 'FRUIT\\Ink\\Rendering\\Plugin');
     GeneralUtility::requireOnce(ExtensionManagementUtility::extPath('ink', 'Classes/Rendering/Plugin.php'));
     GeneralUtility::requireOnce(ExtensionManagementUtility::extPath('ink', 'Classes/Rendering/Image.php'));
     GeneralUtility::requireOnce(ExtensionManagementUtility::extPath('ink', 'Classes/Rendering/Menu.php'));
     $objectManager = new ObjectManager();
     /** @var Dispatcher $signalSlot */
     $signalSlot = $objectManager->get('TYPO3\\CMS\\Extbase\\SignalSlot\\Dispatcher');
     $returnData = $signalSlot->dispatch(__CLASS__, 'renderer', array('renderer' => $renderer));
     $renderer = $returnData['renderer'];
     if (isset($renderer[$CType])) {
         $className = $renderer[$CType];
         /** @var RenderingInterface $renderObject */
         $renderObject = $objectManager->get($className);
         $lines = $renderObject->render($this->cObj, $this->conf);
     } else {
         $lines[] = 'CType: ' . $CType . ' have no rendering definitions';
     }
     $content = implode(LF, $lines);
     return trim($content, CRLF . TAB);
 }
开发者ID:ercuement,项目名称:ink,代码行数:38,代码来源:PlainRenderer.php

示例7: __construct

 /**
  * initialize dependencies an build TSFE
  */
 public function __construct()
 {
     $objectManager = new ObjectManager();
     /** @var BackendUriBuilder $viewHelper */
     $this->uriBuilder = $objectManager->get('I4W\\Fileshare\\Mvc\\Web\\Routing\\BackendUriBuilder');
     $this->configuration = $objectManager->get('I4W\\Fileshare\\TYPO3\\Configuration\\ExtensionConfiguration');
     $this->buildTSFE();
 }
开发者ID:kschu91,项目名称:TYPO3-fileshare,代码行数:11,代码来源:LinkGeneration.php

示例8: __construct

 /**
  * PlanningUtility constructor.
  */
 public function __construct()
 {
     $this->objM = GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
     $this->sessionRepository = $this->objM->get(AnySessionRepository::class);
     $this->db = $GLOBALS['TYPO3_DB'];
     $dateTimeFormats = $this->db->getDateTimeFormats('tx_sessions_domain_model_session');
     $this->dbDateTimeFormat = $dateTimeFormats['datetime']['format'];
 }
开发者ID:t3dd,项目名称:T3DD16.Backend,代码行数:11,代码来源:PlanningUtility.php

示例9: init

 /**
  * initializes this object
  */
 protected function init()
 {
     $this->objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
     $this->database = $GLOBALS['TYPO3_DB'];
     $this->fileRepository = $this->objectManager->get('TYPO3\\CMS\\Core\\Resource\\FileRepository');
     $fileFactory = ResourceFactory::getInstance();
     $this->storageObject = $fileFactory->getStorageObject($this->storageUid);
 }
开发者ID:wernert,项目名称:t3ext-dam_falmigration,代码行数:11,代码来源:AbstractTask.php

示例10: getProvider

 /**
  * Get a provider
  *
  * @param string $name
  *
  * @throws InvalidArgumentValueException
  * @return SitemapProviderInterface
  */
 public static function getProvider($name)
 {
     if (!isset(self::$provider[$name])) {
         throw new InvalidArgumentValueException($name . ' not exists');
     }
     $obj = new ObjectManager();
     return $obj->get($name);
 }
开发者ID:bernhardberger,项目名称:google_services,代码行数:16,代码来源:SitemapProvider.php

示例11: setUp

 /**
  * SetUp
  */
 public function setUp()
 {
     parent::setUp();
     $this->importDataSet(__DIR__ . '/Fixtures/tx_schedulertimeline_domain_model_log.xml');
     $this->importDataSet(__DIR__ . '/Fixtures/tx_scheduler_task.xml');
     $this->objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
     $this->logRepository = $this->objectManager->get('AOE\\SchedulerTimeline\\Domain\\Repository\\LogRepository');
 }
开发者ID:AOEpeople,项目名称:scheduler_timeline,代码行数:11,代码来源:LogRepositoryTest.php

示例12: isValid

 /**
  * Checks if the given value is a valid recaptcha.
  *
  * @param mixed $value The value that should be validated
  * @throws InvalidVariableException
  */
 public function isValid($value)
 {
     $response = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('g-recaptcha-response');
     if ($response !== null) {
         // Only check if a response is set
         $configurationManager = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager');
         $fullTs = $configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
         $reCaptchaSettings = $fullTs['plugin.']['tx_sfeventmgt.']['settings.']['reCaptcha.'];
         if (isset($reCaptchaSettings) && is_array($reCaptchaSettings) && isset($reCaptchaSettings['secretKey']) && $reCaptchaSettings['secretKey']) {
             $ch = curl_init();
             $fields = ['secret' => $reCaptchaSettings['secretKey'], 'response' => $response];
             // url-ify the data for the POST
             $fieldsString = '';
             foreach ($fields as $key => $value) {
                 $fieldsString .= $key . '=' . $value . '&';
             }
             rtrim($fieldsString, '&');
             // set the url, number of POST vars, POST data
             curl_setopt($ch, CURLOPT_URL, 'https://www.google.com/recaptcha/api/siteverify');
             curl_setopt($ch, CURLOPT_POST, count($fields));
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
             curl_setopt($ch, CURLOPT_POSTFIELDS, $fieldsString);
             // execute post
             $resultCH = json_decode(curl_exec($ch));
             if (!(bool) $resultCH->success) {
                 $this->addError(LocalizationUtility::translate('validation.possible_robot', 'sf_event_mgt'), 1231423345);
             }
         } else {
             throw new InvalidVariableException(LocalizationUtility::translate('error.no_secretKey', 'sf_event_mgt'), 1358349150);
         }
     }
 }
开发者ID:derhansen,项目名称:sf_event_mgt,代码行数:38,代码来源:RecaptchaValidator.php

示例13: 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;
 }
开发者ID:busynoggin,项目名称:cicregister,代码行数:33,代码来源:Behavior.php

示例14: analyseUserGroups

 /**
  * Analyses user groups
  *
  * @param array $reports
  * @return void
  */
 protected function analyseUserGroups(&$reports)
 {
     /** @var \AOE\AoeIpauth\Domain\Service\FeEntityService $service */
     $service = $this->objectManager->get('AOE\\AoeIpauth\\Domain\\Service\\FeEntityService');
     $userGroups = $service->findAllGroupsWithIpAuthentication();
     if (empty($userGroups)) {
         // Message that no user group has IP authentication
         $reports[] = $this->objectManager->get('TYPO3\\CMS\\Reports\\Status', 'IP Usergroup Authentication', 'No user groups with IP authentication found', 'No user groups were found anywhere that are active and have an automatic IP authentication enabled.' . 'Your current IP is: <strong>' . $this->myIp . '</strong>', \TYPO3\CMS\Reports\Status::INFO);
     } else {
         $thisUrl = urlencode(GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'));
         $userGroupInfo = '<br /><br /><table cellpadding="4" cellspacing="0" border="0">';
         $userGroupInfo .= '<thead><tr><th style="padding-bottom: 10px;">User Group</th><th>IP/Range</th></tr></thead>';
         $userGroupInfo .= '<tbody>';
         // Add user group strings
         foreach ($userGroups as $group) {
             $uid = $group['uid'];
             $ips = implode(', ', $group['tx_aoeipauth_ip']);
             $fullRecord = BackendUtility::getRecord('fe_groups', $uid);
             $title = $fullRecord['title'];
             $button = '<a title="Edit record" onclick="window.location.href=\'alt_doc.php?returnUrl=' . $thisUrl . '&amp;edit[fe_groups][' . $uid . ']=edit\'; return false;" href="#">' . '<span class="t3-icon t3-icon-actions t3-icon-actions-document t3-icon-document-open">&nbsp;</span>' . '</a>';
             $userGroupInfo .= '<tr><td style="padding: 0 20px 0 0;">' . $button . $title . '</td><td>' . $ips . '</td></tr>';
         }
         $userGroupInfo .= '</tbody>';
         $userGroupInfo .= '</table>';
         $userGroupInfo .= '<br /><br />Your current IP is: <strong>' . $this->myIp . '</strong>';
         // Inform about the groups
         $reports[] = $this->objectManager->get('tx_reports_reports_status_Status', 'IP Usergroup Authentication', 'Some groups with automatic IP authentication were found.', $userGroupInfo, \TYPO3\CMS\Reports\Status::OK);
     }
 }
开发者ID:bernhardberger,项目名称:aoe_ipauth,代码行数:35,代码来源:IpGroupAuthenticationStatus.php

示例15: initializePresets

 /**
  * Initialize presets of feature
  *
  * @param array $postValues List of $POST values of this feature
  * @return void
  * @throws Exception
  */
 public function initializePresets(array $postValues)
 {
     // Give feature sub array of $POST values to preset and set to own property
     $featurePostValues = array();
     if (!empty($postValues[$this->name])) {
         $featurePostValues = $postValues[$this->name];
     }
     $this->postValues = $featurePostValues;
     $isNonCustomPresetActive = false;
     $customPresetFound = false;
     foreach ($this->presetRegistry as $presetClass) {
         /** @var PresetInterface $presetInstance */
         $presetInstance = $this->objectManager->get($presetClass);
         if (!$presetInstance instanceof PresetInterface) {
             throw new Exception('Preset ' . $presetClass . ' does not implement PresetInterface', 1378644821);
         }
         $presetInstance->setPostValues($featurePostValues);
         // Custom preset is set active if no preset before is active
         if ($presetInstance->isActive()) {
             $isNonCustomPresetActive = true;
         }
         if ($presetInstance instanceof CustomPresetInterface && !$isNonCustomPresetActive) {
             // Throw Exception if two custom presets are registered
             if ($customPresetFound === true) {
                 throw new Exception('Preset ' . $presetClass . ' implements CustomPresetInterface, but another' . ' custom preset is already registered', 1378645039);
             }
             /** @var CustomPresetInterface $presetInstance */
             $presetInstance->setActive();
             $customPresetFound = true;
         }
         $this->presetInstances[] = $presetInstance;
     }
 }
开发者ID:rickymathew,项目名称:TYPO3.CMS,代码行数:40,代码来源:AbstractFeature.php


注:本文中的TYPO3\CMS\Extbase\Object\ObjectManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。