import v1.1.0_RC2 | 2009-09-20
This commit is contained in:
@ -17,7 +17,7 @@
|
||||
* @subpackage Framework
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id$
|
||||
* @version $Id: Abstract.php 17795 2009-08-24 19:04:01Z ralph $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -105,25 +105,47 @@ abstract class Zend_Tool_Project_Provider_Abstract extends Zend_Tool_Framework_P
|
||||
* - if an enpoint variable has been registered in teh client registry - key=workingDirectory
|
||||
* - if an ENV variable with the key ZFPROJECT_PATH is found
|
||||
*
|
||||
* @
|
||||
* @param $loadProfileFlag bool Whether or not to throw an exception when no profile is found
|
||||
* @param $projectDirectory string The project directory to use to search
|
||||
* @param $searchParentDirectories bool Whether or not to search upper level direcotries
|
||||
* @return Zend_Tool_Project_Profile
|
||||
*/
|
||||
protected function _loadProfile($loadProfileFlag = self::NO_PROFILE_THROW_EXCEPTION, $projectDirectory = null)
|
||||
protected function _loadProfile($loadProfileFlag = self::NO_PROFILE_THROW_EXCEPTION, $projectDirectory = null, $searchParentDirectories = true)
|
||||
{
|
||||
|
||||
|
||||
// use the cwd if no directory was provided
|
||||
if ($projectDirectory == null) {
|
||||
$projectDirectory = getcwd();
|
||||
} elseif (realpath($projectDirectory) == false) {
|
||||
throw new Zend_Tool_Project_Provider_Exception('The $projectDirectory supplied does not exist.');
|
||||
}
|
||||
|
||||
$profile = new Zend_Tool_Project_Profile();
|
||||
$profile->setAttribute('projectDirectory', $projectDirectory);
|
||||
|
||||
if ($profile->isLoadableFromFile()) {
|
||||
$profile->loadFromFile();
|
||||
$this->_loadedProfile = $profile;
|
||||
|
||||
$parentDirectoriesArray = explode(DIRECTORY_SEPARATOR, ltrim($projectDirectory, DIRECTORY_SEPARATOR));
|
||||
while ($parentDirectoriesArray) {
|
||||
$projectDirectoryAssembled = implode(DIRECTORY_SEPARATOR, $parentDirectoriesArray);
|
||||
|
||||
if (DIRECTORY_SEPARATOR !== "\\") {
|
||||
$projectDirectoryAssembled = DIRECTORY_SEPARATOR . $projectDirectoryAssembled;
|
||||
}
|
||||
|
||||
$profile->setAttribute('projectDirectory', $projectDirectoryAssembled);
|
||||
if ($profile->isLoadableFromFile()) {
|
||||
chdir($projectDirectoryAssembled);
|
||||
|
||||
$profile->loadFromFile();
|
||||
$this->_loadedProfile = $profile;
|
||||
break;
|
||||
}
|
||||
|
||||
// break after first run if we are not to check upper directories
|
||||
if ($searchParentDirectories == false) {
|
||||
break;
|
||||
}
|
||||
|
||||
array_pop($parentDirectoriesArray);
|
||||
}
|
||||
|
||||
|
||||
if ($this->_loadedProfile == null) {
|
||||
if ($loadProfileFlag == self::NO_PROFILE_THROW_EXCEPTION) {
|
||||
throw new Zend_Tool_Project_Provider_Exception('A project profile was not found.');
|
||||
@ -183,6 +205,21 @@ abstract class Zend_Tool_Project_Provider_Abstract extends Zend_Tool_Framework_P
|
||||
$projectProfileFile->getContext()->save();
|
||||
}
|
||||
|
||||
protected function _getContentForContext(Zend_Tool_Project_Context_Interface $context, $methodName, $parameters)
|
||||
{
|
||||
$storage = $this->_registry->getStorage();
|
||||
if (!$storage->isEnabled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!class_exists('Zend_Tool_Project_Context_Content_Engine')) {
|
||||
require_once 'Zend/Tool/Project/Context/Content/Engine.php';
|
||||
}
|
||||
|
||||
$engine = new Zend_Tool_Project_Context_Content_Engine($storage);
|
||||
return $engine->getContent($context, $methodName, $parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* _loadContextClassesIntoRegistry() - This is called by the constructor
|
||||
* so that child providers can provide a list of contexts to load into the
|
||||
@ -198,4 +235,4 @@ abstract class Zend_Tool_Project_Provider_Abstract extends Zend_Tool_Framework_P
|
||||
$registry->addContextClass($contextClass);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
* @subpackage Framework
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id$
|
||||
* @version $Id: Action.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -17,7 +17,7 @@
|
||||
* @subpackage Framework
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id$
|
||||
* @version $Id: Controller.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -17,7 +17,7 @@
|
||||
* @subpackage Framework
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id$
|
||||
* @version $Id: Exception.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -17,7 +17,7 @@
|
||||
* @subpackage Framework
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id$
|
||||
* @version $Id: Form.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -17,7 +17,7 @@
|
||||
* @subpackage Framework
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id$
|
||||
* @version $Id: Manifest.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -17,7 +17,7 @@
|
||||
* @subpackage Framework
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id$
|
||||
* @version $Id: Model.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -17,7 +17,7 @@
|
||||
* @subpackage Framework
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id$
|
||||
* @version $Id: Module.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -17,7 +17,7 @@
|
||||
* @subpackage Framework
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id$
|
||||
* @version $Id: Profile.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -17,7 +17,7 @@
|
||||
* @subpackage Framework
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id$
|
||||
* @version $Id: Project.php 16972 2009-07-22 18:44:24Z ralph $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -34,12 +34,14 @@ require_once 'Zend/Tool/Project/Provider/Abstract.php';
|
||||
class Zend_Tool_Project_Provider_Project extends Zend_Tool_Project_Provider_Abstract
|
||||
{
|
||||
|
||||
protected $_specialties = array('Info');
|
||||
|
||||
/**
|
||||
* create()
|
||||
*
|
||||
* @param string $path
|
||||
*/
|
||||
public function create($path)
|
||||
public function create($path, $nameOfProfile = null, $fileOfProfile = null)
|
||||
{
|
||||
if ($path == null) {
|
||||
$path = getcwd();
|
||||
@ -62,9 +64,24 @@ class Zend_Tool_Project_Provider_Project extends Zend_Tool_Project_Provider_Abst
|
||||
throw new Zend_Tool_Framework_Client_Exception('A project already exists here');
|
||||
}
|
||||
|
||||
$profileData = null;
|
||||
|
||||
if ($fileOfProfile != null && file_exists($fileOfProfile)) {
|
||||
$profileData = file_get_contents($fileOfProfile);
|
||||
}
|
||||
|
||||
$storage = $this->_registry->getStorage();
|
||||
if ($profileData == '' && $nameOfProfile != null && $storage->isEnabled()) {
|
||||
$profileData = $storage->get('project/profiles/' . $nameOfProfile . '.xml');
|
||||
}
|
||||
|
||||
if ($profileData == '') {
|
||||
$profileData = $this->_getDefaultProfile();
|
||||
}
|
||||
|
||||
$newProfile = new Zend_Tool_Project_Profile(array(
|
||||
'projectDirectory' => $path,
|
||||
'profileData' => $this->_getDefaultProfile()
|
||||
'profileData' => $profileData
|
||||
));
|
||||
|
||||
$newProfile->loadFromData();
|
||||
@ -75,6 +92,21 @@ class Zend_Tool_Project_Provider_Project extends Zend_Tool_Project_Provider_Abst
|
||||
$resource->create();
|
||||
}
|
||||
}
|
||||
|
||||
public function show()
|
||||
{
|
||||
$this->_registry->getResponse()->appendContent('You probably meant to run "show project.info".', array('color' => 'yellow'));
|
||||
}
|
||||
|
||||
public function showInfo()
|
||||
{
|
||||
$profile = $this->_loadProfile(self::NO_PROFILE_RETURN_FALSE);
|
||||
if (!$profile) {
|
||||
$this->_registry->getResponse()->appendContent('No project found.');
|
||||
} else {
|
||||
$this->_registry->getResponse()->appendContent('Working with project located at: ' . $profile->getAttribute('projectDirectory'));
|
||||
}
|
||||
}
|
||||
|
||||
protected function _getDefaultProfile()
|
||||
{
|
||||
|
@ -1,99 +1,97 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
/** Zend_Tool_Project_Provider_Abstract */
|
||||
require_once 'Zend/Tool/Project/Provider/Abstract.php';
|
||||
|
||||
/** Zend_Tool_Project_Provider_Exception */
|
||||
require_once 'Zend/Tool/Project/Provider/Exception.php';
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Tool_Project_Provider_ProjectProvider extends Zend_Tool_Project_Provider_Abstract
|
||||
{
|
||||
|
||||
/**
|
||||
* createResource()
|
||||
*
|
||||
* @param Zend_Tool_Project_Profile $profile
|
||||
* @param string $projectProviderName
|
||||
* @param string $actionNames
|
||||
* @return Zend_Tool_Project_Profile_Resource
|
||||
*/
|
||||
public static function createResource(Zend_Tool_Project_Profile $profile, $projectProviderName, $actionNames = null)
|
||||
{
|
||||
|
||||
if (!is_string($projectProviderName)) {
|
||||
/**
|
||||
* @see Zend_Tool_Project_Provider_Exception
|
||||
*/
|
||||
require_once 'Zend/Tool/Project/Provider/Exception.php';
|
||||
throw new Zend_Tool_Project_Provider_Exception('Zend_Tool_Project_Provider_Controller::createResource() expects \"projectProviderName\" is the name of a project provider resource to create.');
|
||||
}
|
||||
|
||||
$profileSearchParams = array();
|
||||
$profileSearchParams[] = 'projectProvidersDirectory';
|
||||
|
||||
$projectProvider = $profile->createResourceAt($profileSearchParams, 'projectProviderFile', array('projectProviderName' => $projectProviderName, 'actionNames' => $actionNames));
|
||||
|
||||
return $projectProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* getName()
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'ProjectProvider';
|
||||
}
|
||||
|
||||
/**
|
||||
* Create stub for Zend_Tool Project Provider
|
||||
*
|
||||
* @var string $name class name for new Zend_Tool Project Provider
|
||||
* @var array|string $actions list of provider methods
|
||||
* @throws Zend_Tool_Project_Provider_Exception
|
||||
*/
|
||||
public function create($name, $actions = null)
|
||||
{
|
||||
$profile = $this->_loadProfileRequired();
|
||||
|
||||
$projectProvider = self::createResource($profile, $name, $actions);
|
||||
|
||||
if ($this->_registry->getRequest()->isPretend()) {
|
||||
$this->_registry->getResponse()->appendContent('Would create a project provider named ' . $name
|
||||
. ' in location ' . $projectProvider->getPath()
|
||||
);
|
||||
} else {
|
||||
$this->_registry->getResponse()->appendContent('Creating a project provider named ' . $name
|
||||
. ' in location ' . $projectProvider->getPath()
|
||||
);
|
||||
$projectProvider->create();
|
||||
$this->_storeProfile();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: ProjectProvider.php 17452 2009-08-08 08:27:54Z yoshida@zend.co.jp $
|
||||
*/
|
||||
|
||||
/** @see Zend_Tool_Project_Provider_Abstract */
|
||||
require_once 'Zend/Tool/Project/Provider/Abstract.php';
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Tool_Project_Provider_ProjectProvider extends Zend_Tool_Project_Provider_Abstract
|
||||
{
|
||||
|
||||
/**
|
||||
* createResource()
|
||||
*
|
||||
* @param Zend_Tool_Project_Profile $profile
|
||||
* @param string $projectProviderName
|
||||
* @param string $actionNames
|
||||
* @return Zend_Tool_Project_Profile_Resource
|
||||
*/
|
||||
public static function createResource(Zend_Tool_Project_Profile $profile, $projectProviderName, $actionNames = null)
|
||||
{
|
||||
|
||||
if (!is_string($projectProviderName)) {
|
||||
/**
|
||||
* @see Zend_Tool_Project_Provider_Exception
|
||||
*/
|
||||
require_once 'Zend/Tool/Project/Provider/Exception.php';
|
||||
throw new Zend_Tool_Project_Provider_Exception('Zend_Tool_Project_Provider_Controller::createResource() expects \"projectProviderName\" is the name of a project provider resource to create.');
|
||||
}
|
||||
|
||||
$profileSearchParams = array();
|
||||
$profileSearchParams[] = 'projectProvidersDirectory';
|
||||
|
||||
$projectProvider = $profile->createResourceAt($profileSearchParams, 'projectProviderFile', array('projectProviderName' => $projectProviderName, 'actionNames' => $actionNames));
|
||||
|
||||
return $projectProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* getName()
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'ProjectProvider';
|
||||
}
|
||||
|
||||
/**
|
||||
* Create stub for Zend_Tool Project Provider
|
||||
*
|
||||
* @var string $name class name for new Zend_Tool Project Provider
|
||||
* @var array|string $actions list of provider methods
|
||||
* @throws Zend_Tool_Project_Provider_Exception
|
||||
*/
|
||||
public function create($name, $actions = null)
|
||||
{
|
||||
$profile = $this->_loadProfileRequired();
|
||||
|
||||
$projectProvider = self::createResource($profile, $name, $actions);
|
||||
|
||||
if ($this->_registry->getRequest()->isPretend()) {
|
||||
$this->_registry->getResponse()->appendContent('Would create a project provider named ' . $name
|
||||
. ' in location ' . $projectProvider->getPath()
|
||||
);
|
||||
} else {
|
||||
$this->_registry->getResponse()->appendContent('Creating a project provider named ' . $name
|
||||
. ' in location ' . $projectProvider->getPath()
|
||||
);
|
||||
$projectProvider->create();
|
||||
$this->_storeProfile();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
* @subpackage Framework
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id$
|
||||
* @version $Id: Test.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -17,7 +17,7 @@
|
||||
* @subpackage Framework
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id$
|
||||
* @version $Id: View.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
*/
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user