本文整理汇总了PHP中TYPO3\CMS\Extbase\Object\ObjectManager::get方法的典型用法代码示例。如果您正苦于以下问题:PHP ObjectManager::get方法的具体用法?PHP ObjectManager::get怎么用?PHP ObjectManager::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Extbase\Object\ObjectManager
的用法示例。
在下文中一共展示了ObjectManager::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
}
}
示例2: 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) {
}
}
示例3: 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();
}
示例4: callModule
/**
* This method forwards the call to Bootstrap's run() method. This method is invoked by the mod.php
* function of TYPO3.
*
* @param string $moduleSignature
* @throws \RuntimeException
* @return boolean TRUE, if the request request could be dispatched
* @see run()
*/
public function callModule($moduleSignature)
{
if (!isset($GLOBALS['TBE_MODULES']['_configuration'][$moduleSignature])) {
return FALSE;
}
$moduleConfiguration = $GLOBALS['TBE_MODULES']['_configuration'][$moduleSignature];
// Check permissions and exit if the user has no permission for entry
$GLOBALS['BE_USER']->modAccess($moduleConfiguration, TRUE);
$id = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id');
if ($id && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($id)) {
// Check page access
$permClause = $GLOBALS['BE_USER']->getPagePermsClause(TRUE);
$access = is_array(\TYPO3\CMS\Backend\Utility\BackendUtility::readPageAccess((int) $id, $permClause));
if (!$access) {
throw new \RuntimeException('You don\'t have access to this page', 1289917924);
}
}
// BACK_PATH is the path from the typo3/ directory from within the
// directory containing the controller file. We are using mod.php dispatcher
// and thus we are already within typo3/ because we call typo3/mod.php
$GLOBALS['BACK_PATH'] = '';
$configuration = array('extensionName' => $moduleConfiguration['extensionName'], 'pluginName' => $moduleSignature);
if (isset($moduleConfiguration['vendorName'])) {
$configuration['vendorName'] = $moduleConfiguration['vendorName'];
}
$bootstrap = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Core\\BootstrapInterface');
$content = $bootstrap->run('', $configuration);
print $content;
return TRUE;
}
示例5: process
/**
* The main method called by the controller
*
* Iterates over the configured post processors and calls them with their
* own settings
*
* @return string HTML messages from the called processors
*/
public function process()
{
$html = '';
if (is_array($this->postProcessorTypoScript)) {
$keys = ArrayUtility::filterAndSortByNumericKeys($this->postProcessorTypoScript);
foreach ($keys as $key) {
if (!(int) $key || strpos($key, '.') !== false) {
continue;
}
$className = false;
$processorName = $this->postProcessorTypoScript[$key];
$processorArguments = array();
if (isset($this->postProcessorTypoScript[$key . '.'])) {
$processorArguments = $this->postProcessorTypoScript[$key . '.'];
}
if (class_exists($processorName, true)) {
$className = $processorName;
} else {
$classNameExpanded = 'TYPO3\\CMS\\Form\\PostProcess\\' . ucfirst(strtolower($processorName)) . 'PostProcessor';
if (class_exists($classNameExpanded, true)) {
$className = $classNameExpanded;
}
}
if ($className !== false) {
$processor = $this->objectManager->get($className, $this->form, $processorArguments);
if ($processor instanceof PostProcessorInterface) {
$processor->setControllerContext($this->controllerContext);
$html .= $processor->process();
}
}
}
}
return $html;
}
示例6: 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');
}
示例7: 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');
}
示例8: 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;
}
}
示例9: 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 . '&edit[fe_groups][' . $uid . ']=edit\'; return false;" href="#">' . '<span class="t3-icon t3-icon-actions t3-icon-actions-document t3-icon-document-open"> </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);
}
}
示例10: convertDependenciesToObjects
/**
* Converts string dependencies to an object storage of dependencies
*
* @param string $dependencies
* @return \SplObjectStorage
*/
public function convertDependenciesToObjects($dependencies)
{
$dependenciesObject = new \SplObjectStorage();
$unserializedDependencies = unserialize($dependencies);
if (!is_array($unserializedDependencies)) {
return $dependenciesObject;
}
foreach ($unserializedDependencies as $dependencyType => $dependencyValues) {
// Dependencies might be given as empty string, e.g. conflicts => ''
if (!is_array($dependencyValues)) {
continue;
}
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->get(\TYPO3\CMS\Extensionmanager\Domain\Model\Dependency::class);
$dependencyObject->setType($dependencyType);
$dependencyObject->setIdentifier($dependency);
$dependencyObject->setLowestVersion($lowest);
$dependencyObject->setHighestVersion($highest);
$dependenciesObject->attach($dependencyObject);
unset($dependencyObject);
}
}
}
return $dependenciesObject;
}
示例11: 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);
}
示例12: 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);
}
示例13: setUp
/**
*
*/
public function setUp()
{
$this->testExtensionsToLoad = array('typo3conf/ext/aoe_ipauth');
parent::setUp();
/** @var $this->objectManager \TYPO3\CMS\Extbase\Object\ObjectManager */
$this->objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
$this->fixture = $this->objectManager->get('AOE\\AoeIpauth\\Hooks\\Staticfilecache');
}
示例14: clearAllCaches
/**
* Clear all caches. Therefor it is necessary to login a BE_USER. You have to prevent
* this function to run on live systems!!!
*/
public function clearAllCaches()
{
/** @var TYPO3\CMS\Core\DataHandling\DataHandler $tce */
$tce = $this->objectManager->get(TYPO3\CMS\Core\DataHandling\DataHandler::class);
$tce->start(array(), array());
$tce->admin = 1;
$tce->clear_cacheCmd('all');
}
示例15: __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();
}