Пример #1
0
 /**
  *
  * all properties that have a setter in this class and a getter in the reflection class will be set here
  *
  * @param Tx_ExtensionBuilder_Reflection_PropertyReflection $propertyReflection
  * @return void
  */
 public function mapToReflectionProperty($propertyReflection)
 {
     if ($propertyReflection instanceof Tx_ExtensionBuilder_Reflection_PropertyReflection) {
         $tags = $propertyReflection->getTagsValues();
         // just to initialize the docCommentParser
         foreach ($this as $key => $value) {
             $setterMethodName = 'set' . t3lib_div::underscoredToUpperCamelCase($key);
             $getterMethodName = 'get' . t3lib_div::underscoredToUpperCamelCase($key);
             // map properties of reflection class to this class
             if (method_exists($propertyReflection, $getterMethodName) && method_exists($this, $setterMethodName) && $key != 'value') {
                 $this->{$setterMethodName}($propertyReflection->{$getterMethodName}());
             }
             $isMethodName = 'is' . t3lib_div::underscoredToUpperCamelCase($key);
             // map properties of reflection class to this class
             if (method_exists($propertyReflection, $setterMethodName) && method_exists($this, $isMethodName)) {
                 $this->{$setterMethodName}($propertyReflection->{$isMethodName}());
             }
         }
         // This is not yet used later on. The type is not validated, so it might be anything!!
         if (isset($this->tags['var'])) {
             $parts = preg_split('/\\s/', $this->tags['var'][0], 2);
             $this->varType = $parts[0];
         } else {
             t3lib_div::devLog('No var type set for property $' . $this->name . ' in class ' . $propertyReflection->getDeclaringClass()->name, 'extension_builder');
         }
         if (empty($this->tags)) {
             // strange behaviour in php ReflectionProperty->getDescription(). A backslash is added to the description
             $this->description = str_replace("\n/", '', $this->description);
             $this->description = trim($this->description);
             $this->setTag('var', 'mixed // please define a var type here');
         }
     }
 }
	/**
	 * Solution for {outer.{inner}} problem with variables in fluid
	 *
	 * @param $obj  object Object
	 * @param $prop	string Property
	 */
	public function render($obj, $prop) {
		if (is_object($obj) && method_exists($obj, 'get' . t3lib_div::underscoredToUpperCamelCase($prop))) {
			return $obj->{'get' . t3lib_div::underscoredToUpperCamelCase($prop)}();
		} elseif (is_array($obj)) {
			if (array_key_exists($prop, $obj)) {
				return $obj[$prop];
			}
		}
		return NULL;
	}
Пример #3
0
 public function getRecurranceSubtype($config)
 {
     $type = trim($config['row']['recurrance_type']);
     if (empty($type)) {
         return;
     }
     $className = 'Tx_CzSimpleCal_Recurrance_Type_' . t3lib_div::underscoredToUpperCamelCase($type);
     $callback = array($className, 'getSubtypes');
     if (!class_exists($className) || !is_callable($callback)) {
         return;
     }
     $config['items'] = call_user_func($callback);
 }
Пример #4
0
 /**
  * create a new instance with data from a given array
  * 
  * @param $data
  * @return Tx_CzSimpleCal_Tests_Mocks_IsRecurringMock
  */
 public static function fromArray($data)
 {
     $className = __CLASS__;
     $obj = new $className();
     foreach ($data as $name => $value) {
         $methodName = 'set' . t3lib_div::underscoredToUpperCamelCase($name);
         // check if there is a setter defined (use of is_callable to check if the scope is public)
         if (!is_callable(array($obj, $methodName))) {
             throw new InvalidArgumentException(sprintf('Could not find the %s method to set %s in %s.', $methodName, $name, get_class($obj)));
         }
         call_user_func(array($obj, $methodName), $value);
     }
     return $obj;
 }
Пример #5
0
 public function __construct($methodName, $methodReflection = NULL)
 {
     $this->setName($methodName);
     if ($methodReflection instanceof Tx_ExtensionBuilder_Reflection_MethodReflection) {
         $methodReflection->getTagsValues();
         // just to initialize the docCommentParser
         foreach ($this as $key => $value) {
             $setterMethodName = 'set' . t3lib_div::underscoredToUpperCamelCase($key);
             $getterMethodName = 'get' . t3lib_div::underscoredToUpperCamelCase($key);
             // map properties of reflection class to this class
             if (method_exists($methodReflection, $getterMethodName) && method_exists($this, $setterMethodName)) {
                 $this->{$setterMethodName}($methodReflection->{$getterMethodName}());
                 //t3lib_div::print_array($getterMethodName);
             }
         }
         if (empty($this->tags)) {
             // strange behaviour in php ReflectionProperty->getDescription(). A backslash is added to the description
             $this->description = str_replace("\n/", '', $this->description);
             $this->description = trim($this->description);
             //$this->setTag('return','void');
         }
     }
 }
<?php

if (!defined('TYPO3_MODE')) {
    die('Access denied.');
}
$extensionName = t3lib_div::underscoredToUpperCamelCase($_EXTKEY);
/**
 * Registers a Plugin to be listed in the Backend. You also have to configure the Dispatcher in ext_localconf.php.
 */
if ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$_EXTKEY]['registerSinglePlugin']) {
    Tx_Extbase_Utility_Extension::registerPlugin($_EXTKEY, 'Pi1', 'A Blog Example');
    $pluginSignature = strtolower($extensionName) . '_pi1';
    $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist'][$pluginSignature] = 'select_key';
    $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform,recursive';
    t3lib_extMgm::addPiFlexFormValue($pluginSignature, 'FILE:EXT:' . $_EXTKEY . '/Configuration/FlexForms/flexform_list.xml');
} else {
    t3lib_div::loadTCA('tt_content');
    // These dividers are a little trick to group these items in the plugin selector
    $TCA['tt_content']['columns']['list_type']['config']['items'][] = array('Blog Example', '--div--', t3lib_extMgm::extRelPath($_EXTKEY) . 'ext_icon.gif');
    Tx_Extbase_Utility_Extension::registerPlugin($_EXTKEY, 'BlogList', 'List of Blogs (BlogExample)');
    Tx_Extbase_Utility_Extension::registerPlugin($_EXTKEY, 'PostList', 'List of Posts (BlogExample)');
    Tx_Extbase_Utility_Extension::registerPlugin($_EXTKEY, 'PostSingle', 'Single Post (BlogExample)');
    Tx_Extbase_Utility_Extension::registerPlugin($_EXTKEY, 'BlogAdmin', 'Admin Plugin (BlogExample)');
    $TCA['tt_content']['columns']['list_type']['config']['items'][] = array('', '--div--');
    $pluginSignature = strtolower($extensionName) . '_postlist';
    $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist'][$pluginSignature] = 'select_key';
    $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform,recursive';
    t3lib_extMgm::addPiFlexFormValue($pluginSignature, 'FILE:EXT:' . $_EXTKEY . '/Configuration/FlexForms/flexform_list.xml');
}
if (TYPO3_MODE === 'BE') {
    /**
Пример #7
0
<?php

if (!defined('TYPO3_MODE')) {
    die('Access denied.');
}
Tx_Extbase_Utility_Extension::registerPlugin($_EXTKEY, 'Pi1', 'TeamPoint-Supportformular: Formular-Selektor');
Tx_Extbase_Utility_Extension::registerPlugin($_EXTKEY, 'Pi2', 'TeamPoint-Supportformular: Formular');
Tx_Extbase_Utility_Extension::registerPlugin($_EXTKEY, 'Pi3', 'TeamPoint-Supportformular: Link zu einem Einzelformular');
t3lib_extMgm::addStaticFile($_EXTKEY, 'Configuration/TypoScript', 'TeamPoint-Supportformular');
t3lib_extMgm::addLLrefForTCAdescr('tx_jhesupportform_domain_model_form', 'EXT:jhe_supportform/Resources/Private/Language/locallang_csh_tx_jhesupportform_domain_model_form.xml');
t3lib_extMgm::allowTableOnStandardPages('tx_jhesupportform_domain_model_form');
$TCA['tx_jhesupportform_domain_model_form'] = array('ctrl' => array('title' => 'LLL:EXT:jhe_supportform/Resources/Private/Language/locallang_db.xml:tx_jhesupportform_domain_model_form', 'label' => 'uid', 'tstamp' => 'tstamp', 'crdate' => 'crdate', 'cruser_id' => 'cruser_id', 'dividers2tabs' => TRUE, 'versioningWS' => 2, 'versioning_followPages' => TRUE, 'origUid' => 't3_origuid', 'languageField' => 'sys_language_uid', 'transOrigPointerField' => 'l10n_parent', 'transOrigDiffSourceField' => 'l10n_diffsource', 'delete' => 'deleted', 'enablecolumns' => array('disabled' => 'hidden', 'starttime' => 'starttime', 'endtime' => 'endtime'), 'searchFields' => '', 'dynamicConfigFile' => t3lib_extMgm::extPath($_EXTKEY) . 'Configuration/TCA/Form.php', 'iconfile' => t3lib_extMgm::extRelPath($_EXTKEY) . 'Resources/Public/Icons/tx_jhesupportform_domain_model_form.gif'));
t3lib_extMgm::addLLrefForTCAdescr('tx_jhesupportform_domain_model_selector', 'EXT:jhe_supportform/Resources/Private/Language/locallang_csh_tx_jhesupportform_domain_model_selector.xml');
t3lib_extMgm::allowTableOnStandardPages('tx_jhesupportform_domain_model_selector');
$TCA['tx_jhesupportform_domain_model_selector'] = array('ctrl' => array('title' => 'LLL:EXT:jhe_supportform/Resources/Private/Language/locallang_db.xml:tx_jhesupportform_domain_model_selector', 'label' => 'uid', 'tstamp' => 'tstamp', 'crdate' => 'crdate', 'cruser_id' => 'cruser_id', 'dividers2tabs' => TRUE, 'versioningWS' => 2, 'versioning_followPages' => TRUE, 'origUid' => 't3_origuid', 'languageField' => 'sys_language_uid', 'transOrigPointerField' => 'l10n_parent', 'transOrigDiffSourceField' => 'l10n_diffsource', 'delete' => 'deleted', 'enablecolumns' => array('disabled' => 'hidden', 'starttime' => 'starttime', 'endtime' => 'endtime'), 'searchFields' => '', 'dynamicConfigFile' => t3lib_extMgm::extPath($_EXTKEY) . 'Configuration/TCA/Selector.php', 'iconfile' => t3lib_extMgm::extRelPath($_EXTKEY) . 'Resources/Public/Icons/tx_jhesupportform_domain_model_selector.gif'));
$extensionName = strtolower(t3lib_div::underscoredToUpperCamelCase($_EXTKEY));
$pluginName = strtolower('Pi3');
$pluginSignature = $extensionName . '_' . $pluginName;
$TCA['tt_content']['types']['list']['subtypes_excludelist'][$pluginSignature] = 'layout,select_key,pages,recursive';
$TCA['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform';
t3lib_extMgm::addPiFlexFormValue($pluginSignature, 'FILE:EXT:' . $_EXTKEY . '/Configuration/Flexform/Link.xml');
Пример #8
0
 /**
  * If a JSON file is found in the extensions directory the previous version
  * of the extension is build to compare it with the new configuration coming
  * from the extension builder input
  *
  * @param Tx_ExtensionBuilder_Domain_Model_Extension $extension
  */
 public function initialize(Tx_ExtensionBuilder_Domain_Model_Extension $extension)
 {
     $this->extension = $extension;
     $this->extensionDirectory = $this->extension->getExtensionDir();
     $this->extClassPrefix = 'Tx_' . t3lib_div::underscoredToUpperCamelCase($this->extension->getExtensionKey());
     if (!$this->classParser instanceof Tx_ExtensionBuilder_Utility_ClassParser) {
         $this->injectClassParser(t3lib_div::makeInstance('Tx_ExtensionBuilder_Utility_ClassParser'));
     }
     $this->settings = $this->configurationManager->getExtensionBuilderSettings();
     // defaults
     $this->previousExtensionDirectory = $this->extensionDirectory;
     $this->previousExtensionKey = $this->extension->getExtensionKey();
     if ($extension->isRenamed()) {
         $this->previousExtensionDirectory = $extension->getPreviousExtensionDirectory();
         $this->previousExtensionKey = $extension->getOriginalExtensionKey();
         $this->extensionRenamed = TRUE;
         t3lib_div::devlog('Extension renamed: ' . $this->previousExtensionKey . ' => ' . $this->extension->getExtensionKey(), 'extension_builder', 1, array('$previousExtensionDirectory ' => $this->previousExtensionDirectory));
     }
     // Rename the old kickstarter.json file to ExtensionBuilder.json
     if (file_exists($this->previousExtensionDirectory . 'kickstarter.json')) {
         rename($this->previousExtensionDirectory . 'kickstarter.json', $this->previousExtensionDirectory . Tx_ExtensionBuilder_Configuration_ConfigurationManager::EXTENSION_BUILDER_SETTINGS_FILE);
     }
     if (file_exists($this->previousExtensionDirectory . Tx_ExtensionBuilder_Configuration_ConfigurationManager::EXTENSION_BUILDER_SETTINGS_FILE)) {
         $extensionSchemaBuilder = t3lib_div::makeInstance('Tx_ExtensionBuilder_Service_ExtensionSchemaBuilder');
         $jsonConfig = $this->configurationManager->getExtensionBuilderConfiguration($this->previousExtensionKey, FALSE);
         t3lib_div::devlog('old JSON:' . $this->previousExtensionDirectory . 'ExtensionBuilder.json', 'extension_builder', 0, $jsonConfig);
         $this->previousExtension = $extensionSchemaBuilder->build($jsonConfig);
         $oldDomainObjects = $this->previousExtension->getDomainObjects();
         foreach ($oldDomainObjects as $oldDomainObject) {
             $this->oldDomainObjects[$oldDomainObject->getUniqueIdentifier()] = $oldDomainObject;
             t3lib_div::devlog('Old domain object: ' . $oldDomainObject->getName() . ' - ' . $oldDomainObject->getUniqueIdentifier(), 'extension_builder');
         }
         // now we store all renamed domainObjects in an array to enable detection of renaming in
         // relationProperties (property->getForeignModel)
         // we also build an array with the new unique identifiers to detect deleting of domainObjects
         $currentDomainsObjects = array();
         foreach ($this->extension->getDomainObjects() as $domainObject) {
             if (isset($this->oldDomainObjects[$domainObject->getUniqueIdentifier()])) {
                 if ($this->oldDomainObjects[$domainObject->getUniqueIdentifier()]->getName() != $domainObject->getName()) {
                     $renamedDomainObjects[$domainObject->getUniqueIdentifier()] = $domainObject;
                 }
             }
             $currentDomainsObjects[$domainObject->getUniqueIdentifier()] = $domainObject;
         }
         // remove deleted objects
         foreach ($oldDomainObjects as $oldDomainObject) {
             if (!isset($currentDomainsObjects[$oldDomainObject->getUniqueIdentifier()])) {
                 $this->removeDomainObjectFiles($oldDomainObject);
             }
         }
     }
     spl_autoload_register('Tx_ExtensionBuilder_Utility_ClassLoader::loadClass', FALSE, TRUE);
 }
Пример #9
0
 protected function order($events)
 {
     if (!$this->arguments['orderBy'] && !$this->arguments['order']) {
         return $events;
     } elseif ($this->arguments['orderBy']) {
         $this->orderGetMethodName = 'get' . t3lib_div::underscoredToUpperCamelCase($this->arguments['orderBy']);
         if (usort($events, array($this, "orderByObjectMethod"))) {
             return $events;
         } else {
             throw new RuntimeException(sprintf('%s could not sort the events.', get_class($this)));
         }
     }
 }
 /**
  * cover all cases:
  * 1. extend TYPO3 class like fe_users (no mapping table needed)
  *
  * @param Tx_ExtensionBuilder_Domain_Model_DomainObject $domainObject
  */
 private function validateMapping(Tx_ExtensionBuilder_Domain_Model_DomainObject $domainObject)
 {
     $parentClass = $domainObject->getParentClass();
     $tableName = $domainObject->getMapToTable();
     $extensionPrefix = 'Tx_' . t3lib_div::underscoredToUpperCamelCase($domainObject->getExtension()->getExtensionKey()) . '_Domain_Model_';
     if (!empty($parentClass)) {
         $classConfiguration = $this->configurationManager->getExtbaseClassConfiguration($parentClass);
         t3lib_div::devlog('class settings ' . $parentClass, 'extension_builder', 0, $classConfiguration);
         if (!isset($classConfiguration['tableName'])) {
             if (!$tableName) {
                 $this->validationResult['errors'][] = new Tx_ExtensionBuilder_Domain_Exception_ExtensionException('Mapping configuration error in domain object ' . $domainObject->getName() . ': The mapping table could not be detected from Extbase Configuration. Please enter a table name', self::ERROR_MAPPING_NO_TABLE);
             }
         } else {
             // get the table name from the parent class configuration
             $tableName = $classConfiguration['tableName'];
         }
         if (!class_exists($parentClass, TRUE)) {
             $this->validationResult['errors'][] = new Tx_ExtensionBuilder_Domain_Exception_ExtensionException('Mapping configuration error in domain object ' . $domainObject->getName() . ': the parent class ' . $parentClass . 'seems not to exist ', self::ERROR_MAPPING_NO_PARENTCLASS);
         }
     }
     if ($tableName) {
         if (strpos($extensionPrefix, $tableName) !== FALSE) {
             // the domainObject extends a class of the same extension
             if (!$parentClass) {
                 $this->validationResult['errors'][] = new Tx_ExtensionBuilder_Domain_Exception_ExtensionException('Mapping configuration error in domain object ' . $domainObject->getName() . ': you have to define a parent class if you map to a table of another domain object of the same extension ', self::ERROR_MAPPING_NO_PARENTCLASS);
             }
         }
         if (!isset($GLOBALS['TCA'][$tableName])) {
             $this->validationResult['errors'][] = new Tx_ExtensionBuilder_Domain_Exception_ExtensionException('There is no entry for table "' . $tableName . '" of ' . $domainObject->getName() . ' in TCA. For technical reasons you can only extend tables with TCA configuration.', self::ERROR_MAPPING_NO_TCA);
         }
     }
     if (isset($GLOBALS['TCA'][$tableName]['ctrl']['type'])) {
         $dataTypeRes = $GLOBALS['TYPO3_DB']->sql_query('DESCRIBE ' . $tableName);
         while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($dataTypeRes)) {
             if ($row['Field'] == $GLOBALS['TCA'][$tableName]['ctrl']['type']) {
                 if (strpos($row['Type'], 'int') !== FALSE) {
                     $this->validationResult['warnings'][] = new Tx_ExtensionBuilder_Domain_Exception_ExtensionException('The configured type field for table "' . $tableName . '" is of type ' . $row['Type'] . '<br />This means the type field can not be used for defining the record type. <br />You have to configure the mappings yourself if you want to map to this<br /> table or extend the correlated class', self::ERROR_MAPPING_WRONG_TYPEFIELD_CONFIGURATION);
                 }
             }
         }
     }
 }
Пример #11
0
 /**
  * returns the name of the domain repository class name, if it is an aggregateroot.
  *
  * @return string
  */
 public function getDomainRepositoryClassName()
 {
     if (!$this->aggregateRoot) {
         return '';
     }
     return 'Tx_' . t3lib_div::underscoredToUpperCamelCase($this->extension->getExtensionKey()) . '_Domain_Repository_' . $this->getName() . 'Repository';
 }
Пример #12
0
 /**
  * @test
  * @see t3lib_div::underscoredToUpperCamelCase
  */
 public function canConvertFromUnderscoredToUpperCamelCase()
 {
     $this->assertEquals('BlogExample', t3lib_div::underscoredToUpperCamelCase('blog_example'));
     $this->assertEquals('Blogexample', t3lib_div::underscoredToUpperCamelCase('blogexample'));
 }
Пример #13
0
 public static function convertLowerUnderscoreToUpperCamelCase($camelCasedString)
 {
     return t3lib_div::underscoredToUpperCamelCase($camelCasedString);
 }
	/**
	 * Is {outer.{inner}} a datetime?
	 *
	 * @param	$obj	object Object
	 * @param	$prop	string Property
	 * @return	bool
	 */
	public function render($obj, $prop) {
		if (is_object($obj) && method_exists($obj, 'get' . t3lib_div::underscoredToUpperCamelCase($prop))) {
			$mixed = $obj->{'get' . t3lib_div::underscoredToUpperCamelCase($prop)}();
		}
		return method_exists($mixed, 'getTimestamp');
	}
Пример #15
0
 /**
  *
  * @param Tx_ExtensionBuilder_Service_CodeGenerator $codeGenerator
  * @param Tx_ExtensionBuilder_Domain_Model_Extension $extension
  * @param boolean roundtrip enabled?
  *
  * @return void
  */
 public function initialize(Tx_ExtensionBuilder_Service_CodeGenerator $codeGenerator, Tx_ExtensionBuilder_Domain_Model_Extension $extension, $roundTripEnabled)
 {
     $this->codeGenerator = $codeGenerator;
     $this->extension = $extension;
     $settings = $extension->getSettings();
     if ($roundTripEnabled) {
         $this->roundTripService->initialize($this->extension);
     }
     $this->settings = $settings['classBuilder'];
     $this->extensionDirectory = $this->extension->getExtensionDir();
     $this->extClassPrefix = 'Tx_' . t3lib_div::underscoredToUpperCamelCase($this->extension->getExtensionKey());
 }
 /**
  * Enable the import of actions configuration of installed extensions
  * by importing the settings from $TYPO3_CONF_VARS
  * @param array $extensionConfigurationJSON
  * @return array
  */
 protected function importExistingActionConfiguration(array $extensionConfigurationJSON)
 {
     if (isset($extensionConfigurationJSON['properties']['plugins'])) {
         $extKey = $extensionConfigurationJSON['properties']['extensionKey'];
         if (t3lib_extMgm::isLoaded($extKey)) {
             foreach ($extensionConfigurationJSON['properties']['plugins'] as &$pluginJSON) {
                 if (isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][t3lib_div::underscoredToUpperCamelCase($extKey)]['plugins'][ucfirst($pluginJSON['key'])]['controllers'])) {
                     $controllerActionCombinationsConfig = "";
                     $nonCachableActionConfig = "";
                     $pluginJSON['actions'] = array();
                     foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][t3lib_div::underscoredToUpperCamelCase($extKey)]['plugins'][ucfirst($pluginJSON['key'])]['controllers'] as $controllerName => $controllerConfig) {
                         if (isset($controllerConfig['actions'])) {
                             $controllerActionCombinationsConfig .= $controllerName . '=>' . implode(',', $controllerConfig['actions']) . LF;
                         }
                         if (isset($controllerConfig['nonCacheableActions'])) {
                             $nonCachableActionConfig .= $controllerName . '=>' . implode(',', $controllerConfig['nonCacheableActions']) . LF;
                         }
                     }
                     if (!empty($controllerActionCombinationsConfig)) {
                         $pluginJSON['actions']['controllerActionCombinations'] = $controllerActionCombinationsConfig;
                     }
                     if (!empty($nonCachableActionConfig)) {
                         $pluginJSON['actions']['noncacheableActions'] = $nonCachableActionConfig;
                     }
                 }
             }
         }
     }
     return $extensionConfigurationJSON;
 }