/**
  * Datasource constructor, creates the Configuration, Connection and DocumentManager objects
  *
  * ### You can pass the following configuration options
  *
  *	- server: name of the server that will be used to connect to Mongo (default: `localhost`)
  *	- database: name of the database to use when connecting to Mongo (default: `cake`)
  *	- documentPaths: array containing a list of full path names where Document classes can be located (default: `App::path('Model')`)
  *	- proxyDir: full path to the directory that will contain the generated proxy classes for each document (default: `TMP . 'cache'`)
  *	- proxyNamespace: string representing the namespace the proxy classes will reside in (default: `Proxies`)
  *	- hydratorDir: directory well the hydrator classes will be generated in (default: `TMP . 'cache'`)
  *	- hydratorNamespace:  string representing the namespace the hydrator classes will reside in (default: `Hydrators`)
  *
  * @param arary $config
  * @param boolean $autoConnect whether this object should attempt connection on creation
  * @throws MissingConnectionException if it was not possible to connect to MongoDB
  */
 public function __construct($config = array(), $autoConnect = true)
 {
     $modelPaths = $this->_cleanupPaths(App::path('Model'));
     $this->_baseConfig = array('proxyDir' => TMP . 'cache', 'proxyNamespace' => 'Proxies', 'hydratorDir' => TMP . 'cache', 'hydratorNamespace' => 'Hydrators', 'server' => 'localhost', 'database' => 'cake', 'documentPaths' => $modelPaths, 'prefix' => null);
     foreach (CakePlugin::loaded() as $plugin) {
         $this->_baseConfig['documentPaths'] = array_merge($this->_baseConfig['documentPaths'], $this->_cleanupPaths(App::path('Model', $plugin)));
     }
     parent::__construct($config);
     extract($this->config, EXTR_OVERWRITE);
     $configuration = new Configuration();
     $configuration->setProxyDir($proxyDir);
     $configuration->setProxyNamespace($proxyNamespace);
     $configuration->setHydratorDir($hydratorDir);
     $configuration->setHydratorNamespace($hydratorNamespace);
     $configuration->setDefaultDB($database);
     $configuration->setMetadataDriverImpl($this->_getMetadataReader($documentPaths));
     if (Configure::read('debug') === 0) {
         $configuration->setAutoGenerateHydratorClasses(false);
         $configuration->setAutoGenerateProxyClasses(false);
         $configuration->setMetadataCacheImpl(new ApcCache());
     }
     $this->configuration = $configuration;
     $this->connection = new Connection($server, array(), $configuration);
     $this->documentManager = DocumentManager::create($this->connection, $configuration);
     $this->documentManager->getEventManager()->addEventListener(array(Events::prePersist, Events::preUpdate, Events::preRemove, Events::postPersist, Events::postUpdate, Events::postRemove), $this);
     try {
         if ($autoConnect) {
             $this->connect();
         }
     } catch (Exception $e) {
         throw new MissingConnectionException(array('class' => get_class($this)));
     }
     $this->setupLogger();
 }
 /**
  * Run $input through Closure compiler
  *
  * @param string $filename Filename being generated.
  * @param string $input Contents of file
  * @throws Exception $e
  * @return Compressed file
  */
 public function output($filename, $input)
 {
     $output = null;
     $jar = $this->_findExecutable(App::path('vendors'), $this->_settings['path']);
     //Closure works better if you specify an input file. Also supress warnings by default
     $tmpFile = tempnam(TMP, 'CLOSURE');
     file_put_contents($tmpFile, $input);
     $options = array('js' => $tmpFile) + $this->_settings;
     $options = array_diff_key($options, array('path' => null, 'paths' => null, 'target' => null, 'theme' => null));
     $cmd = 'java -jar "' . $jar . '"';
     foreach ($options as $key => $value) {
         $cmd .= sprintf(' --%s=%s', $key, $value);
     }
     try {
         $output = $this->_runCmd($cmd, null);
     } catch (Exception $e) {
         //If there is an error need to remove tmpFile.
         // @codingStandardsIgnoreStart
         @unlink($tmpFile);
         // @codingStandardsIgnoreStart
         throw $e;
     }
     // @codingStandardsIgnoreStart
     @unlink($tmpFile);
     // @codingStandardsIgnoreStart
     return $output;
 }
Exemple #3
0
 public function _getFiles($type)
 {
     $files = App::objects($type);
     # lib
     $paths = (array) App::path($type . 's');
     $libFiles = App::objects($type, $paths[0] . 'lib' . DS, false);
     $plugins = App::objects('plugin');
     if (!empty($plugins)) {
         foreach ($plugins as $plugin) {
             $pluginFiles = App::objects($type, App::pluginPath($plugin) . $type . 's' . DS, false);
             if (!empty($pluginFiles)) {
                 foreach ($pluginFiles as $t) {
                     $files[] = $t;
                     //"$plugin.$type";
                 }
             }
         }
     }
     $files = array_merge($files, $libFiles);
     $files = array_unique($files);
     $appIndex = array_search('App', $files);
     if ($appIndex !== false) {
         unset($files[$appIndex]);
     }
     # no test/tmp files etc (helper.test.php or helper.OLD.php)
     foreach ($files as $key => $file) {
         if (strpos($file, '.') !== false || !preg_match('/^[\\da-zA-Z_]+$/', $file)) {
             unset($files[$key]);
         }
     }
     return $files;
 }
Exemple #4
0
  /**
   * Looks for the view file according to the given view name.
   *
   * @return string the view file path, false if the view file does not exist
   */
  public function getLayoutFile() {
    if( $this->layout == NULL ) {
        return false;
    }

    return App::path( array( 'view', $this->layout ) );
  }
 public function startup()
 {
     $this->_welcome();
     $this->out('TwitterBootstrap Shell');
     $this->hr();
     $this->pluginPath = App::pluginPath($this->pluginName);
     $paths = array_unique(array_merge(App::path('Vendor', $this->pluginName), App::path('Vendor')));
     foreach ($paths as $path) {
         $dir = 'twitter' . DS . 'bootstrap' . DS;
         if (is_dir($path . $dir . self::IMG_DIR) && is_dir($path . $dir . self::JS_DIR) && is_dir($path . $dir . self::LESS_DIR)) {
             $this->bootstrapPath = $path . $dir;
             break;
         }
         $dir = 'bootstrap' . DS;
         if (is_dir($path . $dir . self::IMG_DIR) && is_dir($path . $dir . self::JS_DIR) && is_dir($path . $dir . self::LESS_DIR)) {
             $this->bootstrapPath = $path . $dir;
             break;
         }
     }
     if (!$this->bootstrapPath) {
         $this->out('<error>Bootstrap files were not found.</error>');
         exit(0);
     }
     $this->Folder = new Folder($this->bootstrapPath);
 }
 /**
  * start test
  *
  * @return void
  **/
 function startTest()
 {
     $this->Version =& new MigrationVersion(array('connection' => 'test_suite'));
     $plugins = $this->plugins = App::path('plugins');
     $plugins[] = dirname(dirname(dirname(__FILE__))) . DS . 'test_app' . DS . 'plugins' . DS;
     App::build(array('plugins' => $plugins), true);
 }
Exemple #7
0
 /**
  * Overwrite shell initialize to dynamically load all Queue Related Tasks.
  *
  * @return void
  */
 public function initialize()
 {
     $paths = App::path('Console/Command/Task');
     foreach ($paths as $path) {
         $Folder = new Folder($path);
         $res = array_merge($this->tasks, $Folder->find('Queue.*\\.php'));
         foreach ($res as &$r) {
             $r = basename($r, 'Task.php');
         }
         $this->tasks = $res;
     }
     $plugins = CakePlugin::loaded();
     foreach ($plugins as $plugin) {
         $pluginPaths = App::path('Console/Command/Task', $plugin);
         foreach ($pluginPaths as $pluginPath) {
             $Folder = new Folder($pluginPath);
             $res = $Folder->find('Queue.*Task\\.php');
             foreach ($res as &$r) {
                 $r = $plugin . '.' . basename($r, 'Task.php');
             }
             $this->tasks = array_merge($this->tasks, $res);
         }
     }
     parent::initialize();
     $this->QueuedTask->initConfig();
 }
Exemple #8
0
 /**
  * Get the jobs that are currently queued. Returns the jobs as objects
  * structured like :
  * 
  *
  *  - pId = process ID of job.
  *  - time = time job was enetered.
  *  - delay = delay the job was told to wait before execution.
  *  - object = the actual object or Closure that will execute the job.
  *  - method = the method to call on the object.
  *  - vars = the variables to be passed to the method.
  *
  *
  *  @return array An array of job objects.
  */
 public function jobs()
 {
     exec('ps -ef | grep "php[[:space:]]' . \App::path() . '/public/index\\.php[[:space:]]resolve"', $jobs);
     $f = 'php ' . \App::path() . '/public/index.php resolve';
     $j = array();
     foreach ($jobs as $k => $v) {
         if (stripos($v, $f) !== false) {
             $v = preg_replace('!\\s+!', ' ', $v);
             $j[] = $v;
         }
         //if
     }
     //foreach
     foreach ($j as $k => $job) {
         $job = explode(' ', $job, 15);
         $j[$k] = new \stdClass();
         $j[$k]->pId = $job[1];
         $j[$k]->time = $job[4];
         $j[$k]->delay = $job[10];
         $j[$k]->object = unserialize(base64_decode($job[11]));
         $j[$k]->method = $job[12];
         $j[$k]->vars = $job[13] == 'disco-no-variable' ? '' : unserialize(base64_decode($job[13]));
     }
     //foreach
     return $j;
 }
	/**
	 * startTest method
	 *
	 * @return void
	 * @access public
	 */
	function startTest() {
		$this->Dispatcher =& new TestProjectTaskMockShellDispatcher();
		$this->Dispatcher->shellPaths = App::path('shells');
		$this->Task =& new MockProjectTask($this->Dispatcher);
		$this->Task->Dispatch =& $this->Dispatcher;
		$this->Task->path = TMP . 'tests' . DS;
	}
 /**
  * execute
  *
  * Overriden so all the interactive options take defaults
  *
  * @return void
  */
 public function execute()
 {
     $this->_getPaths();
     $path = $this->_paths[0];
     $this->params['extract-core'] = 'no';
     if (!isset($this->params['ignore-model-validation'])) {
         $this->params['ignore-model-validation'] = true;
     }
     $pluginPaths = App::path('plugins');
     if ($this->_isExtractingApp()) {
         $this->_exclude = array_merge($this->_exclude, $pluginPaths);
     }
     if (!isset($this->params['output'])) {
         $this->params['output'] = $path . 'Locale' . DS;
     }
     $this->params['merge'] = 'no';
     $this->params['overwrite'] = true;
     // set plugin param if a plugin path is given and the default domain is set
     if (preg_match('/Plugin\\/(?P<plugin>.+)\\//', $path, $matches) && isset($this->_defaultDomain)) {
         $this->params['plugin'] = $matches['plugin'];
     } else {
         $this->params['paths'] = $path;
     }
     parent::execute();
 }
Exemple #11
0
 /**
  * Overwrite shell initialize to dynamically load all Queue Related Tasks.
  *
  * @return void
  */
 public function initialize()
 {
     $this->_loadModels();
     $x = App::objects('Queue.Task');
     //'Console/Command/Task'
     //$x = App::path('Task', 'Queue');
     $paths = App::path('Console/Command/Task');
     foreach ($paths as $path) {
         $Folder = new Folder($path);
         $this->tasks = array_merge($this->tasks, $Folder->find('Queue.*\\.php'));
     }
     $plugins = App::objects('plugin');
     foreach ($plugins as $plugin) {
         $pluginPaths = App::path('Console/Command/Task', $plugin);
         foreach ($pluginPaths as $pluginPath) {
             $Folder = new Folder($pluginPath);
             $res = $Folder->find('Queue.*Task\\.php');
             foreach ($res as &$r) {
                 $r = $plugin . '.' . basename($r, 'Task.php');
             }
             $this->tasks = array_merge($this->tasks, $res);
         }
     }
     //Config can be overwritten via local app config.
     Configure::load('Queue.queue');
     $conf = (array) Configure::read('Queue');
     //merge with default configuration vars.
     Configure::write('Queue', array_merge(['maxruntime' => DAY, 'cleanuptimeout' => MONTH], $conf));
 }
Exemple #12
0
 /**
  * Loads a plugin and optionally loads bootstrapping, routing files or loads a initialization function
  *
  * Examples:
  *
  * 	`CakePlugin::load('DebugKit')` will load the DebugKit plugin and will not load any bootstrap nor route files
  *	`CakePlugin::load('DebugKit', array('bootstrap' => true, 'routes' => true))` will load the bootstrap.php and routes.php files
  * 	`CakePlugin::load('DebugKit', array('bootstrap' => false, 'routes' => true))` will load routes.php file but not bootstrap.php
  * 	`CakePlugin::load('DebugKit', array('bootstrap' => array('config1', 'config2')))` will load config1.php and config2.php files
  *	`CakePlugin::load('DebugKit', array('bootstrap' => 'aCallableMethod'))` will run the aCallableMethod function to initialize it
  *
  * Bootstrap initialization functions can be expressed as a PHP callback type, including closures. Callbacks will receive two
  * parameters (plugin name, plugin configuration)
  *
  * It is also possible to load multiple plugins at once. Examples:
  *
  * `CakePlugin::load(array('DebugKit', 'ApiGenerator'))` will load the DebugKit and ApiGenerator plugins
  * `CakePlugin::load(array('DebugKit', 'ApiGenerator'), array('bootstrap' => true))` will load bootstrap file for both plugins
  *
  * {{{
  * 	CakePlugin::load(array(
  * 		'DebugKit' => array('routes' => true),
  * 		'ApiGenerator'
  * 		), array('bootstrap' => true))
  * }}}
  *
  * Will only load the bootstrap for ApiGenerator and only the routes for DebugKit
  *
  * @param string|array $plugin name of the plugin to be loaded in CamelCase format or array or plugins to load
  * @param array $config configuration options for the plugin
  * @throws MissingPluginException if the folder for the plugin to be loaded is not found
  * @return void
  */
 public static function load($plugin, $config = array())
 {
     if (is_array($plugin)) {
         foreach ($plugin as $name => $conf) {
             list($name, $conf) = is_numeric($name) ? array($conf, $config) : array($name, $conf);
             self::load($name, $conf);
         }
         return;
     }
     $config += array('bootstrap' => false, 'routes' => false, 'ignoreMissing' => false);
     if (empty($config['path'])) {
         foreach (App::path('plugins') as $path) {
             if (is_dir($path . $plugin)) {
                 self::$_plugins[$plugin] = $config + array('path' => $path . $plugin . DS);
                 break;
             }
             //Backwards compatibility to make easier to migrate to 2.0
             $underscored = Inflector::underscore($plugin);
             if (is_dir($path . $underscored)) {
                 self::$_plugins[$plugin] = $config + array('path' => $path . $underscored . DS);
                 break;
             }
         }
     } else {
         self::$_plugins[$plugin] = $config;
     }
     if (empty(self::$_plugins[$plugin]['path'])) {
         throw new MissingPluginException(array('plugin' => $plugin));
     }
     if (!empty(self::$_plugins[$plugin]['bootstrap'])) {
         self::bootstrap($plugin);
     }
 }
 /**
  * startTest method
  *
  * @return void
  * @access public
  */
 function startTest()
 {
     $this->Dispatcher =& new TestTemplateTaskMockShellDispatcher();
     $this->Task =& new MockTemplateTask($this->Dispatcher);
     $this->Task->Dispatch =& $this->Dispatcher;
     $this->Task->Dispatch->shellPaths = App::path('shells');
 }
Exemple #14
0
 /**
  * Get the content of theme.json file from a theme
  *
  * @param string $alias theme folder name
  * @return array
  */
 public function getData($alias = null)
 {
     if ($alias == null || $alias == 'default') {
         $manifestFile = WWW_ROOT . 'theme.json';
     } else {
         $viewPaths = App::path('views');
         foreach ($viewPaths as $viewPath) {
             if (file_exists($viewPath . 'Themed' . DS . $alias . DS . 'webroot' . DS . 'theme.json')) {
                 $manifestFile = $viewPath . 'Themed' . DS . $alias . DS . 'webroot' . DS . 'theme.json';
                 continue;
             }
         }
         if (!isset($manifestFile)) {
             $manifestFile = WWW_ROOT . 'theme.json';
         }
     }
     if (isset($manifestFile) && file_exists($manifestFile)) {
         $themeData = json_decode(file_get_contents($manifestFile), true);
         if ($themeData == null) {
             $themeData = array();
         }
     } else {
         $themeData = array();
     }
     return $themeData;
 }
 /**
  * Find the paths to all the installed shell themes extensions in the app.
  *
  * @return array Array of bake themes that are installed.
  */
 protected function _findSubthemes()
 {
     $paths = App::path('shells');
     $plugins = App::objects('plugin');
     foreach ($plugins as $plugin) {
         $paths[$plugin] = $this->_pluginPath($plugin) . 'Console' . DS;
     }
     foreach ($paths as $i => $path) {
         $paths[$i] = rtrim($path, DS) . DS;
     }
     $subthemes = array();
     foreach ($paths as $plugin => $path) {
         $Folder = new Folder($path . 'SubTemplates', false);
         $contents = $Folder->read();
         $subDirs = $contents[0];
         foreach ($subDirs as $dir) {
             if (empty($dir) || preg_match('@^skel$|_skel|\\..+$@', $dir)) {
                 continue;
             }
             $Folder = new Folder($path . 'SubTemplates' . DS . $dir);
             $contents = $Folder->read();
             $subDirs = $contents[0];
             $templateDir = $path . 'SubTemplates' . DS . $dir . DS;
             $subthemes[$plugin . '.' . $dir] = $templateDir;
         }
     }
     return $subthemes;
 }
Exemple #16
0
 /**
  * Syncs all of the SSH keys to the git user's authorized_keys file to allow for ssh access
  */
 public function sync_keys()
 {
     $sync_required = $this->Setting->find('first', array('conditions' => array('name' => 'sync_required')));
     //if ($sync_required['Setting']['value'] == 1) {
     $keys = $this->SshKey->find('all');
     $prepared_keys = array();
     $template = 'command="%s %s",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty %s';
     $app_path = App::path('Controller');
     $app_path = $app_path[0];
     $app_path = str_replace('/app/Controller', '', $app_path);
     $cmd = $app_path . 'scm-scripts/git-serve.py';
     $out = '';
     foreach ($keys as $key) {
         $sshkey = $key['SshKey']['key'];
         $userid = $key['User']['id'];
         if (strlen($sshkey) > 40) {
             //sanity check on key
             $content = trim(str_replace(array("\n", "\r"), '', $sshkey));
             $out .= sprintf($template, $cmd, $userid, $content) . "\n";
         }
     }
     file_put_contents('/home/git/.ssh/authorized_keys', $out, LOCK_EX);
     $sync_required['Setting']['value'] = 0;
     $this->Setting->save($sync_required);
     //}
 }
Exemple #17
0
 /**
  * Loads all available event handler classes for enabled plugins
  *
  */
 private function __loadEventHandlers()
 {
     $this->__eventHandlerCache = Cache::read('event_handlers', 'core');
     if (empty($this->__eventHandlerCache)) {
         App::import('Core', 'Folder');
         $folder = new Folder();
         $pluginsPaths = App::path('plugins');
         foreach ($pluginsPaths as $pluginsPath) {
             $folder->cd($pluginsPath);
             $plugins = $folder->read();
             $plugins = $plugins[0];
             if (count($plugins)) {
                 foreach ($plugins as $pluginName) {
                     $filename = $pluginsPath . $pluginName . DS . $pluginName . '_events.php';
                     $className = Inflector::camelize($pluginName . '_events');
                     if (file_exists($filename)) {
                         if (EventCore::__loadEventClass($className, $filename)) {
                             EventCore::__getAvailableHandlers($this->__eventClasses[$className]);
                         }
                     }
                 }
             }
         }
         Cache::write('event_handlers', $this->__eventHandlerCache, 'core');
     }
 }
Exemple #18
0
 /**
  * Overwrite shell initialize to dynamically load all queue related tasks.
  *
  * @return void
  */
 public function initialize()
 {
     // Check for tasks inside plugins and application
     $paths = App::path('Console/Command/Task');
     foreach ($paths as $path) {
         $Folder = new Folder($path);
         $res = array_merge($this->tasks, $Folder->find('Queue.*\\.php'));
         foreach ($res as &$r) {
             $r = basename($r, 'Task.php');
         }
         $this->tasks = $res;
     }
     $plugins = App::objects('plugin');
     foreach ($plugins as $plugin) {
         $pluginPaths = App::path('Console/Command/Task', $plugin);
         foreach ($pluginPaths as $pluginPath) {
             $Folder = new Folder($pluginPath);
             $res = $Folder->find('Queue.*Task\\.php');
             foreach ($res as &$r) {
                 $r = $plugin . '.' . basename($r, 'Task.php');
             }
             $this->tasks = array_merge($this->tasks, $res);
         }
     }
     $conf = Configure::read('Queue');
     if (!is_array($conf)) {
         $conf = [];
     }
     // Merge with default configuration vars.
     Configure::write('Queue', array_merge(['workers' => 3, 'sleepTime' => 10, 'gcprop' => 10, 'defaultWorkerTimeout' => 2 * MINUTE, 'defaultWorkerRetries' => 4, 'workerMaxRuntime' => 0, 'cleanupTimeout' => DAY, 'exitWhenNothingToDo' => false], $conf));
     parent::initialize();
 }
Exemple #19
0
 public function show_captcha()
 {
     if (session_id() == "") {
         session_name("CAKEPHP");
         session_start();
     }
     $vendor_path = App::path('Vendor');
     $path = $vendor_path[0] . 'captcha';
     $imgname = 'bg.jpg';
     $imgpath = $path . DS . 'images' . DS . $imgname;
     $captchatext = md5(time());
     $captchatext = substr($captchatext, 0, 5);
     $_SESSION['captcha'] = $captchatext;
     if (file_exists($imgpath)) {
         $im = imagecreatefromjpeg($imgpath);
         $grey = imagecolorallocate($im, rand(1, 128), 128, 128);
         $font = $path . DS . 'fonts' . DS . '3D_Noise.ttf';
         imagettftext($im, 36, 0, 0, 55, $grey, $font, $captchatext);
         header('Content-Type: image/jpeg');
         header("Cache-control: private, no-cache");
         header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
         header("Pragma: no-cache");
         imagejpeg($im);
         imagedestroy($im);
         ob_flush();
         flush();
     } else {
         echo 'captcha error';
         exit;
     }
 }
Exemple #20
0
 /**
  * start test
  *
  * @return void
  * @access public
  */
 function startTest()
 {
     $this->Dispatch =& new BakeShellMockShellDispatcher();
     $this->Shell =& new MockBakeShell();
     $this->Shell->Dispatch =& $this->Dispatch;
     $this->Shell->Dispatch->shellPaths = App::path('shells');
 }
Exemple #21
0
 /**
  * setup paths for the case.
  *
  * @return void
  */
 public static function setUpBeforeClass()
 {
     self::$paths = array('plugins' => App::path('plugins'), 'View' => App::path('View'), 'vendors' => App::path('vendors'), 'Controller' => App::path('Controller'));
     App::build(array('View' => array(CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'Test' . DS . 'test_app' . DS . 'View' . DS, APP . 'Plugin' . DS . 'DebugKit' . DS . 'View' . DS, CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'View' . DS)), true);
     if (!class_exists('DoppelGangerView')) {
         eval("class DoppelGangerView extends View {}");
     }
 }
 /**
  * startTest method
  *
  * @return void
  * @access public
  */
 public function startTest()
 {
     $this->Dispatcher = new TestProgressBarTaskMockShellDispatcher();
     $this->Dispatcher->shellPaths = App::path('shells');
     $this->Task = new MockProgressBarTask($this->Dispatcher);
     $this->Task->Dispatch = $this->Dispatcher;
     $this->Task->path = TMP . 'tests' . DS;
 }
 /**
  * start test
  *
  * @return void
  **/
 public function setUp()
 {
     $this->Version = new MigrationVersion(array('connection' => 'test'));
     $plugins = $this->plugins = App::path('plugins');
     $plugins[] = dirname(dirname(dirname(__FILE__))) . DS . 'test_app' . DS . 'Plugin' . DS;
     App::build(array('plugins' => $plugins), true);
     CakePlugin::loadAll();
 }
 public function startup(Controller $controller)
 {
     $paths = App::path('View');
     $this->path = $paths[0];
     if ($this->settings['auto']) {
         $this->loadFile($controller->view);
     }
 }
	/**
	 * startTest method
	 *
	 * @return void
	 * @access public
	 */
	function startTest() {
		$this->Dispatcher =& new TestFixtureTaskMockShellDispatcher();
		$this->Task =& new MockFixtureTask();
		$this->Task->Model =& new MockFixtureModelTask();
		$this->Task->Dispatch =& $this->Dispatcher;
		$this->Task->Template =& new TemplateTask($this->Task->Dispatch);
		$this->Task->Dispatch->shellPaths = App::path('shells');
		$this->Task->Template->initialize();
	}
Exemple #26
0
 public static function paths($postfix)
 {
     $base = App::path();
     $paths = array();
     foreach (self::$enabled_modules as $k => $v) {
         $paths[] = $base . '/default/Modules/' . $v . '/' . $postfix;
     }
     return $paths;
 }
Exemple #27
0
 /**
  *  Carrega um datasource.
  *
  *  @param string $datasource Nome do datasource
  *  @return boolean Verdadeiro se o datasource existir e for carregado
  */
 public static function loadDatasource($datasource = null)
 {
     if (!class_exists($datasource)) {
         if (App::path("Datasource", Inflector::underscore($datasource))) {
             App::import("Datasource", Inflector::underscore($datasource));
         }
     }
     return class_exists($datasource);
 }
Exemple #28
0
 public static function delete($alias)
 {
     $viewPath = App::path('View');
     $folder = new Folder($viewPath[0] . 'Themed' . DS . $alias . DS);
     if ($folder->delete()) {
         return true;
     }
     return false;
 }
	/**
	 * startTest method
	 *
	 * @return void
	 * @access public
	 */
	function startTest() {
		$this->Dispatcher =& new TestDbConfigTaskMockShellDispatcher();
		$this->Task =& new MockDbConfigTask($this->Dispatcher);
		$this->Task->Dispatch =& $this->Dispatcher;
		$this->Task->Dispatch->shellPaths = App::path('shells');

		$this->Task->params['working'] = rtrim(APP, DS);
		$this->Task->databaseClassName = 'TEST_DATABASE_CONFIG';
	}
 /**
  * starTest method
  *
  * @return void
  * @access public
  */
 function startTest()
 {
     $this->Dispatcher =& new TestModelTaskMockShellDispatcher();
     $this->Task =& new MockModelTask($this->Dispatcher);
     $this->Task->Dispatch =& $this->Dispatcher;
     $this->Task->Dispatch->shellPaths = App::path('shells');
     $this->Task->Template =& new TemplateTask($this->Task->Dispatch);
     $this->Task->Fixture =& new MockModelTaskFixtureTask();
     $this->Task->Test =& new MockModelTaskFixtureTask();
 }