/** * Short description of method exec * * @access public * @author Cédric Alfonsi, <*****@*****.**> * @param Resource resource * @param string command * @return string */ public static function exec(core_kernel_classes_Resource $resource, $command) { $returnValue = (string) ''; $username = ""; $password = ""; $repository = null; try { if (empty($command)) { throw new Exception(__CLASS__ . ' -> ' . __FUNCTION__ . '() : $command_ must be specified'); } //get context variables if ($resource instanceof core_kernel_versioning_File) { $repository = $resource->getRepository(); } else { if ($resource instanceof core_kernel_versioning_Repository) { $repository = $resource; } else { throw new Exception('The first parameter (resource) should be a File or a Repository'); } } if (is_null($repository)) { throw new Exception('Unable to find the repository to work with for the reference resource (' . $resource->getUri() . ')'); } $username = $repository->getOnePropertyValue(new core_kernel_classes_Property(PROPERTY_GENERIS_VERSIONEDREPOSITORY_LOGIN)); $password = $repository->getOnePropertyValue(new core_kernel_classes_Property(PROPERTY_GENERIS_VERSIONEDREPOSITORY_PASSWORD)); $returnValue = shell_exec('svn --username ' . $username . ' --password ' . $password . ' ' . $command); // var_dump('svn --username ' . $username . ' --password ' . $password . ' ' . $command); // var_dump($returnValue); } catch (Exception $e) { die('Error code `svn_error_command` in ' . $e->getMessage()); } return (string) $returnValue; }
/** * Short description of method getImplementationToDelegateTo * * @access public * @author Cédric Alfonsi, <*****@*****.**> * @param Resource resource * @return core_kernel_versioning_FileInterface */ public function getImplementationToDelegateTo(core_kernel_classes_Resource $resource) { $returnValue = null; $repository = $resource->getRepository(); if (!is_null($repository)) { $VCStype = $repository->getVCSType(); $implClass = ''; // Function of the repository type, define the implementation to attack switch ($VCStype->getUri()) { case PROPERTY_GENERIS_VCS_TYPE_SUBVERSION: $implClass = 'core_kernel_versioning_subversion_File'; break; case PROPERTY_GENERIS_VCS_TYPE_SUBVERSION_WIN: $implClass = 'core_kernel_versioning_subversionWindows_File'; break; case INSTANCE_GENERIS_VCS_TYPE_LOCAL: $implClass = 'core_kernel_versioning_local_File'; break; default: throw new common_exception_Error('unknown Version Control System ' . $VCStype->getLabel() . '(' . $VCStype . ')'); } // If an implementation has been found if (!empty($implClass)) { $reflectionMethod = new ReflectionMethod($implClass, 'singleton'); $delegate = $reflectionMethod->invoke(null); $returnValue = $delegate; } } else { throw new core_kernel_versioning_exception_FileUnversionedException('no repository associated to the aledged versioned file'); } return $returnValue; }