Beispiel #1
0
 /**
  * clear Cache ajax handler
  *
  * @param array              $ajaxParams
  * @param AjaxRequestHandler $ajaxObj
  */
 public function clear($ajaxParams, AjaxRequestHandler $ajaxObj)
 {
     if ($this->isProduction() || !$this->isAdmin()) {
         return;
     }
     /** @var \TYPO3\CMS\Core\Cache\CacheManager $cacheManager */
     $cacheManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager');
     $cacheManager->getCache('autoloader')->flush();
     // Dump new class loading information
     if (GeneralUtility::compat_version('7.0') && !\TYPO3\CMS\Core\Core\Bootstrap::usesComposerClassLoading()) {
         ClassLoadingInformation::dumpClassLoadingInformation();
     }
 }
Beispiel #2
0
 /**
  * Returns the class name for a new instance, taking into account
  * registered implementations for this class
  *
  * @param string $className Base class name to evaluate
  * @return string Final class name to instantiate with "new [classname]
  */
 protected static function getClassName($className)
 {
     if (class_exists($className)) {
         while (static::classHasImplementation($className)) {
             $className = static::getImplementationForClass($className);
         }
     }
     return ClassLoadingInformation::getClassNameForAlias($className);
 }
Beispiel #3
0
 /**
  * Writes class loading information if not yet present
  *
  * @return Bootstrap
  * @internal This is not a public API method, do not use in own extensions
  */
 public function ensureClassLoadingInformationExists()
 {
     if (!self::$usesComposerClassLoading && !ClassLoadingInformation::isClassLoadingInformationAvailable()) {
         ClassLoadingInformation::dumpClassLoadingInformation();
         ClassLoadingInformation::registerClassLoadingInformation();
     }
     return $this;
 }
 /**
  * Resolve a viewhelper name.
  *
  * @param string $namespaceIdentifier Namespace identifier for the view helper.
  * @param string $methodIdentifier Method identifier, might be hierarchical like "link.url"
  * @return string The fully qualified class name of the viewhelper
  */
 protected function resolveViewHelperName($namespaceIdentifier, $methodIdentifier)
 {
     if (isset($this->viewHelperNameToImplementationClassNameRuntimeCache[$namespaceIdentifier][$methodIdentifier])) {
         $name = $this->viewHelperNameToImplementationClassNameRuntimeCache[$namespaceIdentifier][$methodIdentifier];
     } else {
         $explodedViewHelperName = explode('.', $methodIdentifier);
         $namespaceSeparator = strpos($this->namespaces[$namespaceIdentifier], \TYPO3\CMS\Fluid\Fluid::NAMESPACE_SEPARATOR) !== false ? \TYPO3\CMS\Fluid\Fluid::NAMESPACE_SEPARATOR : \TYPO3\CMS\Fluid\Fluid::LEGACY_NAMESPACE_SEPARATOR;
         if (count($explodedViewHelperName) > 1) {
             $className = implode($namespaceSeparator, array_map('ucfirst', $explodedViewHelperName));
         } else {
             $className = ucfirst($explodedViewHelperName[0]);
         }
         $className .= 'ViewHelper';
         $name = $this->namespaces[$namespaceIdentifier] . $namespaceSeparator . $className;
         $name = \TYPO3\CMS\Core\Core\ClassLoadingInformation::getClassNameForAlias($name);
         // The name isn't cached in viewHelperNameToImplementationClassNameRuntimeCache here because the
         // class could be overloaded by extbase object manager. Thus the cache is filled in
         // initializeViewHelperAndAddItToStack after getting the real object from the object manager.
     }
     return $name;
 }
Beispiel #5
0
 /**
  * Internal implementation for getting a class.
  *
  * @param string $className
  * @param array $givenConstructorArguments the list of constructor arguments as array
  * @throws \TYPO3\CMS\Extbase\Object\Exception
  * @throws \TYPO3\CMS\Extbase\Object\Exception\CannotBuildObjectException
  * @return object the built object
  */
 protected function getInstanceInternal($className, $givenConstructorArguments = [])
 {
     $className = $this->getImplementationClassName($className);
     if ($className === \TYPO3\CMS\Extbase\Object\Container\Container::class) {
         return $this;
     }
     if ($className === \TYPO3\CMS\Core\Cache\CacheManager::class) {
         return \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Cache\CacheManager::class);
     }
     if ($className === \TYPO3\CMS\Core\Package\PackageManager::class) {
         return \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Package\PackageManager::class);
     }
     $className = \TYPO3\CMS\Core\Core\ClassLoadingInformation::getClassNameForAlias($className);
     if (isset($this->singletonInstances[$className])) {
         if (!empty($givenConstructorArguments)) {
             throw new \TYPO3\CMS\Extbase\Object\Exception('Object "' . $className . '" fetched from singleton cache, thus, explicit constructor arguments are not allowed.', 1292857934);
         }
         return $this->singletonInstances[$className];
     }
     $classInfo = $this->getClassInfo($className);
     $classIsSingleton = $classInfo->getIsSingleton();
     if (!$classIsSingleton) {
         if (array_key_exists($className, $this->prototypeObjectsWhichAreCurrentlyInstanciated) !== false) {
             throw new \TYPO3\CMS\Extbase\Object\Exception\CannotBuildObjectException('Cyclic dependency in prototype object, for class "' . $className . '".', 1295611406);
         }
         $this->prototypeObjectsWhichAreCurrentlyInstanciated[$className] = true;
     }
     $instance = $this->instanciateObject($classInfo, $givenConstructorArguments);
     $this->injectDependencies($instance, $classInfo);
     $this->initializeObject($instance, $classInfo);
     if (!$classIsSingleton) {
         unset($this->prototypeObjectsWhichAreCurrentlyInstanciated[$className]);
     }
     return $instance;
 }
 /**
  * Determine the type converter to be used. If no converter has been found, an exception is raised.
  *
  * @param mixed $source
  * @param string $targetType
  * @param PropertyMappingConfigurationInterface $configuration
  * @throws Exception\TypeConverterException
  * @throws Exception\InvalidTargetException
  * @return \TYPO3\CMS\Extbase\Property\TypeConverterInterface Type Converter which should be used to convert between $source and $targetType.
  */
 protected function findTypeConverter($source, $targetType, PropertyMappingConfigurationInterface $configuration)
 {
     if ($configuration->getTypeConverter() !== null) {
         return $configuration->getTypeConverter();
     }
     $sourceType = $this->determineSourceType($source);
     if (!is_string($targetType)) {
         throw new Exception\InvalidTargetException('The target type was no string, but of type "' . gettype($targetType) . '"', 1297941727);
     }
     $targetType = $this->parseCompositeType($targetType);
     // This is needed to correctly convert old class names to new ones
     // This compatibility layer will be removed with 7.0
     $targetType = \TYPO3\CMS\Core\Core\ClassLoadingInformation::getClassNameForAlias($targetType);
     $targetType = TypeHandlingUtility::normalizeType($targetType);
     $converter = null;
     if (TypeHandlingUtility::isSimpleType($targetType)) {
         if (isset($this->typeConverters[$sourceType][$targetType])) {
             $converter = $this->findEligibleConverterWithHighestPriority($this->typeConverters[$sourceType][$targetType], $source, $targetType);
         }
     } else {
         $converter = $this->findFirstEligibleTypeConverterInObjectHierarchy($source, $sourceType, $targetType);
     }
     if ($converter === null) {
         throw new Exception\TypeConverterException('No converter found which can be used to convert from "' . $sourceType . '" to "' . $targetType . '".');
     }
     return $converter;
 }
Beispiel #7
0
 /**
  * @param PackageInterface $package
  * @throws \TYPO3\CMS\Core\Exception
  */
 protected function registerTransientClassLoadingInformationForPackage(PackageInterface $package)
 {
     ClassLoadingInformation::registerTransientClassLoadingInformationForPackage($package);
 }
 /**
  * @param PackageInterface $package
  * @throws \TYPO3\CMS\Core\Exception
  */
 protected function registerTransientClassLoadingInformationForPackage(PackageInterface $package)
 {
     if (Bootstrap::usesComposerClassLoading()) {
         return;
     }
     ClassLoadingInformation::registerTransientClassLoadingInformationForPackage($package);
 }
 /**
  * Set a single option (denoted by $optionKey) for the given $typeConverter.
  *
  * @param string $typeConverter class name of type converter
  * @param string $optionKey
  * @param mixed $optionValue
  * @return \TYPO3\CMS\Extbase\Property\PropertyMappingConfiguration this
  * @api
  */
 public function setTypeConverterOption($typeConverter, $optionKey, $optionValue)
 {
     if (strpos($typeConverter, '_') !== false) {
         $typeConverter = ClassLoadingInformation::getClassNameForAlias($typeConverter);
     }
     foreach ($this->getTypeConvertersWithParentClasses($typeConverter) as $typeConverter) {
         $this->configuration[$typeConverter][$optionKey] = $optionValue;
     }
     return $this;
 }
Beispiel #10
0
call_user_func(function () {
    $testbase = new \TYPO3\CMS\Core\Tests\Testbase();
    $testbase->enableDisplayErrors();
    $testbase->defineBaseConstants();
    $testbase->defineSitePath();
    $testbase->defineTypo3ModeBe();
    $testbase->setTypo3TestingContext();
    $testbase->createDirectory(PATH_site . 'typo3conf/ext');
    $testbase->createDirectory(PATH_site . 'typo3temp/assets');
    $testbase->createDirectory(PATH_site . 'typo3temp/var/tests');
    $testbase->createDirectory(PATH_site . 'typo3temp/var/transient');
    $testbase->createDirectory(PATH_site . 'uploads');
    // Retrieve an instance of class loader and inject to core bootstrap
    $classLoaderFilepath = __DIR__ . '/../../../../vendor/autoload.php';
    if (!file_exists($classLoaderFilepath)) {
        die('ClassLoader can\'t be loaded. Please check your path or set an environment variable \'TYPO3_PATH_WEB\' to your root path.');
    }
    $classLoader = (require $classLoaderFilepath);
    \TYPO3\CMS\Core\Core\Bootstrap::getInstance()->initializeClassLoader($classLoader)->setRequestType(TYPO3_REQUESTTYPE_BE | TYPO3_REQUESTTYPE_CLI)->baseSetup();
    // Initialize default TYPO3_CONF_VARS
    $configurationManager = new \TYPO3\CMS\Core\Configuration\ConfigurationManager();
    $GLOBALS['TYPO3_CONF_VARS'] = $configurationManager->getDefaultConfiguration();
    // Avoid failing tests that rely on HTTP_HOST retrieval
    $GLOBALS['TYPO3_CONF_VARS']['SYS']['trustedHostsPattern'] = '.*';
    \TYPO3\CMS\Core\Core\Bootstrap::getInstance()->disableCoreCache()->initializeCachingFramework()->initializePackageManagement(\TYPO3\CMS\Core\Package\UnitTestPackageManager::class);
    if (!\TYPO3\CMS\Core\Core\Bootstrap::usesComposerClassLoading()) {
        // Dump autoload info if in non composer mode
        \TYPO3\CMS\Core\Core\ClassLoadingInformation::dumpClassLoadingInformation();
        \TYPO3\CMS\Core\Core\ClassLoadingInformation::registerClassLoadingInformation();
    }
});
Beispiel #11
0
 /**
  * Writes class loading information if not yet present
  *
  * @return Bootstrap
  * @internal This is not a public API method, do not use in own extensions
  */
 public function ensureClassLoadingInformationExists()
 {
     if (!self::$usesComposerClassLoading && !ClassLoadingInformation::classLoadingInformationExists()) {
         ClassLoadingInformation::writeClassLoadingInformation();
         ClassLoadingInformation::registerClassLoadingInformation();
     }
     return $this;
 }
Beispiel #12
0
 /**
  * Dumps Extension Autoload Information
  *
  * @return \TYPO3\CMS\Install\Status\StatusInterface
  */
 protected function dumpAutoload() : \TYPO3\CMS\Install\Status\StatusInterface
 {
     if (Bootstrap::usesComposerClassLoading()) {
         $message = GeneralUtility::makeInstance(\TYPO3\CMS\Install\Status\NoticeStatus::class);
         $message->setTitle('Skipped generating additional class loading information in composer mode.');
     } else {
         ClassLoadingInformation::dumpClassLoadingInformation();
         $message = GeneralUtility::makeInstance(\TYPO3\CMS\Install\Status\OkStatus::class);
         $message->setTitle('Successfully dumped class loading information for extensions.');
     }
     return $message;
 }
 /**
  * Updates class loading information.
  *
  * This command is only needed during development. The extension manager takes care
  * creating or updating this info properly during extension (de-)activation.
  *
  * @return void
  * @cli
  */
 public function dumpClassLoadingInformationCommand()
 {
     if (Bootstrap::usesComposerClassLoading()) {
         $this->output->outputLine('<error>Class loading information is managed by composer. Use "composer dump-autoload" command to update the information.</error>');
         $this->quit(1);
     } else {
         ClassLoadingInformation::dumpClassLoadingInformation();
         $this->output->outputLine('Class Loading information has been updated.');
     }
 }
Beispiel #14
0
 /**
  * Writes class loading information if not yet present
  *
  * @return Bootstrap
  * @internal This is not a public API method, do not use in own extensions
  * @deprecated since TYPO3 v8, will be removed in TYPO3 v9. Use the Install Tool to dump autoload information.
  */
 public function ensureClassLoadingInformationExists()
 {
     if (!self::$usesComposerClassLoading && !ClassLoadingInformation::isClassLoadingInformationAvailable()) {
         GeneralUtility::logDeprecatedFunction();
         ClassLoadingInformation::dumpClassLoadingInformation();
         ClassLoadingInformation::registerClassLoadingInformation();
     }
     return $this;
 }