function setUp($settingFile = '') { $this->extension = $this->getMock('Tx_ExtensionBuilder_Domain_Model_Extension', array('getExtensionDir')); $extensionKey = 'dummy'; //$dummyExtensionDir = PATH_typo3conf.'ext/extension_builder/Tests/Examples/'.$extensionKey.'/'; vfsStream::setup('testDir'); $dummyExtensionDir = vfsStream::url('testDir') . '/'; $this->extension->setExtensionKey($extensionKey); $this->extension->expects($this->any())->method('getExtensionDir')->will($this->returnValue($dummyExtensionDir)); $yamlParser = new Tx_ExtensionBuilder_Utility_SpycYAMLParser(); $settings = $yamlParser->YAMLLoadString(file_get_contents(PATH_typo3conf . 'ext/extension_builder/Tests/Examples/Settings/settings1.yaml')); $this->extension->setSettings($settings); $configurationManager = t3lib_div::makeInstance('Tx_ExtensionBuilder_Configuration_ConfigurationManager'); $this->classParser = t3lib_div::makeInstance('Tx_ExtensionBuilder_Utility_ClassParser'); $this->roundTripService = $this->getMock($this->buildAccessibleProxy('Tx_ExtensionBuilder_Service_RoundTrip'), array('dummy')); $this->classBuilder = t3lib_div::makeInstance('Tx_ExtensionBuilder_Service_ClassBuilder'); $this->classBuilder->injectConfigurationManager($configurationManager); $this->roundTripService->injectClassBuilder($this->classBuilder); $this->roundTripService->injectConfigurationManager($configurationManager); $this->templateParser = $this->getMock($this->buildAccessibleProxy('Tx_Fluid_Core_Parser_TemplateParser'), array('dummy')); $this->codeGenerator = $this->getMock($this->buildAccessibleProxy('Tx_ExtensionBuilder_Service_CodeGenerator'), array('dummy')); if (class_exists('Tx_Extbase_Object_ObjectManager')) { $this->objectManager = t3lib_div::makeInstance('Tx_Extbase_Object_ObjectManager'); //parent::runBare(); causes a memory exhausted error?? $this->codeGenerator->injectObjectManager($this->objectManager); $this->templateParser->injectObjectManager($this->objectManager); } $this->roundTripService->injectClassParser($this->classParser); $this->roundTripService->initialize($this->extension); $this->classBuilder->injectRoundtripService($this->roundTripService); $this->classBuilder->initialize($this->codeGenerator, $this->extension); $this->codeGenerator->injectTemplateParser($this->templateParser); $this->codeGenerator->injectClassBuilder($this->classBuilder); $this->codeGenerator->setSettings(array('codeTemplateRootPath' => PATH_typo3conf . 'ext/extension_builder/Resources/Private/CodeTemplates/Extbase/', 'extConf' => array('enableRoundtrip' => '1'))); $this->codeGenerator->_set('codeTemplateRootPath', PATH_typo3conf . 'ext/extension_builder/Resources/Private/CodeTemplates/Extbase/'); $this->codeGenerator->_set('enableRoundtrip', true); $this->codeGenerator->_set('extension', $this->extension); }
/** * Dump YAML from PHP array statically * * The dump method, when supplied with an array, will do its best * to convert the array into friendly YAML. Pretty simple. Feel free to * save the returned string as nothing.yaml and pass it around. * * Oh, and you can decide how big the indent is and what the wordwrap * for folding is. Pretty cool -- just pass in 'false' for either if * you want to use the default. * * Indent's default is 2 spaces, wordwrap's default is 40 characters. And * you can turn off wordwrap by passing in 0. * * @access public * @return string * @param array $array PHP array * @param int $indent Pass in false to use the default, which is 2 * @param int $wordwrap Pass in 0 for no wordwrap, false for default (40) */ public static function YAMLDump($array, $indent = false, $wordwrap = false) { $spyc = new Tx_ExtensionBuilder_Utility_SpycYAMLParser(); return $spyc->dump($array, $indent, $wordwrap); }
/** * * @param string $extensionKey * @return array settings */ public function getExtensionSettings($extensionKey) { $settings = array(); $settingsFile = $this->getSettingsFile($extensionKey); if (file_exists($settingsFile)) { $yamlParser = new Tx_ExtensionBuilder_Utility_SpycYAMLParser(); $settings = $yamlParser->YAMLLoadString(file_get_contents($settingsFile)); } else { t3lib_div::devlog('No settings found: ' . $settingsFile, 'extension_builder', 2); } return $settings; }