本文整理汇总了PHP中Module::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP Module::exists方法的具体用法?PHP Module::exists怎么用?PHP Module::exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Module
的用法示例。
在下文中一共展示了Module::exists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: module
/**
* Replaces an autoloader in a module to help development
*
* @param string $module
*
* @return boolean
*/
public static function module($module)
{
if ($module = \Module::exists($module)) {
return static::path($module . 'vendor/autoload.php');
}
return false;
}
示例2: run
/**
* Run the credential importer
*
* @param string $json_file The JSON file that contains a list of the APIs and their credentials
*/
public static function run($json_file = null)
{
if (empty($json_file) || file_exists($json_file) === false) {
exit('You must specify a valid JSON file that contains your credentials.' . PHP_EOL);
}
if (($json = json_decode(file_get_contents($json_file), true)) === null) {
exit('The JSON file does not contain valid JSON text.' . PHP_EOL);
}
// Find the API version to use for importing the keys
$version = 'V1';
if (!empty($json[0]['version'])) {
if (is_int($json[0]['version']) && \Module::exists('V' . $json[0]['version'])) {
\Module::load('V' . $json[0]['version']);
$version = 'V' . $json[0]['version'];
} else {
\Module::load($version);
}
array_shift($json);
} else {
\Module::load($version);
}
$error = false;
foreach ($json as $entry) {
// We need these keys for each entry.
if (!array_key_exists('api', $entry) || !array_key_exists('credentials', $entry)) {
echo \Cli::color('The JSON data is in the wrong format. Skipping.' . PHP_EOL, 'yellow');
$error = true;
continue;
}
if (!is_string($entry['api'])) {
echo \Cli::color('The API name must be a string. Skipping.' . PHP_EOL, 'yellow');
$error = true;
continue;
}
// Make sure that we have credentials to add to the DB.
if (empty($entry['credentials']) || !is_array($entry['credentials'])) {
echo \Cli::color('The array of credentials for ' . $entry['api'] . ' is empty. Skipping.' . PHP_EOL, 'yellow');
$error = true;
continue;
}
$response = call_user_func('\\' . $version . '\\Keyring::set_credentials', $entry['credentials'], $entry['api']);
// Show and log the result
if ($response === true) {
$success_text = 'Successfully imported the credentials for API: ' . $entry['api'];
echo \Cli::color($success_text . PHP_EOL, 'green');
\Log::logger('INFO', 'CLI:ADD_CREDENTIALS', $success_text, __METHOD__, array('api' => $entry['api']));
} else {
$error_text = 'Failed to import the credentials for API: ' . $entry['api'];
echo \Cli::color('Warning: ' . $error_text . PHP_EOL, 'red');
$error = true;
\Log::logger('ERROR', 'CLI:ADD_CREDENTIALS', $error_text, __METHOD__, array('api' => $entry['api']));
}
}
// Display the summary.
if ($error === true) {
echo \Cli::color(PHP_EOL . 'Some credentials were not added to the database. See the error log for more details.' . PHP_EOL, 'red');
} else {
echo \Cli::color(PHP_EOL . 'All credentials were successfully added to the database.' . PHP_EOL, 'green');
}
}
示例3: validate
/**
* Runs the needed checks to see if the value is valid. A non
* true value will be returned if it failed.
*
* @param mixed $value
* @return bool|string
*/
public function validate($value)
{
if (Module::exists($value, $this->checkInstallable)) {
return true;
}
return t('%1$s must be a valid module', I18n::_DTD);
}
示例4: get_all_paths
public function get_all_paths($theme_name = null)
{
$paths = array();
if ($theme_name === null) {
$theme_name = $this->active['name'];
}
$path_prefix = null;
$module_path = null;
if ($this->config['use_modules'] and class_exists('Request', false) and $request = \Request::active() and $module = $request->module) {
// we're using module name prefixing
$path_prefix = $module . DS;
// and modules are in a separate path
is_string($this->config['use_modules']) and $path_prefix = trim($this->config['use_modules'], '\\/') . DS . $path_prefix;
// do we need to check the module too?
$this->config['use_modules'] === true and $module_path = \Module::exists($module) . 'themes' . DS;
}
foreach ($this->get_parent_themes($theme_name) as $theme) {
if ($this->config['use_modules'] and $module) {
$paths[] = $theme['path'] . $path_prefix;
$paths[] = $module_path . $theme['name'] . DS;
}
foreach ($this->paths as $path) {
$paths[] = $path . $theme['name'] . DS;
}
}
return array_filter(array_unique($paths), 'is_dir');
}
示例5: setProjectDefaults
/**
* Sets project defaults such as ACL rules, additional content,
* load order of modules etc.
*
* @return null
*/
protected function setProjectDefaults()
{
$guestInherit = $adminInherit = array('group_root');
foreach ($this->_acl->getRoleTree('group_guest', true) as $role) {
array_unshift($guestInherit, $role['name']);
}
foreach ($this->_acl->getRoleTree('group_admin', true) as $role) {
array_unshift($adminInherit, $role['name']);
}
$aclResources = array('layout_controller_456' => $guestInherit, 'layout_controller_974' => $guestInherit, 'layout_controller_110' => $guestInherit, 'layout_controller_119' => $guestInherit, 'layout_controller_168' => $guestInherit, 'layout_controller_409' => $adminInherit, 'layout_controller_909' => $adminInherit, 'layout_controller_425' => $adminInherit, 'layout_controller_551' => $adminInherit);
foreach ($aclResources as $resource => $roles) {
$this->_acl->allowOnly($resource, $roles);
}
// Setup module load order
if (Module::exists('comments')) {
$comments = new Module('comments');
$comments->setLoadOrder(1);
# Should force it below Shareable by default
}
if (Module::exists('contact')) {
// Set the contact form email to be the same as the initial user
try {
$this->_sql->exec('UPDATE {PREFIX}mod_contact
SET email = (SELECT email FROM {PREFIX}users WHERE id = 2)');
} catch (Exception $e) {
}
}
}
示例6: run
public static function run($task, $args = array())
{
$task = strtolower($task);
// Make sure something is set
if (empty($task) or $task === 'help') {
static::help();
return;
}
$module = false;
list($module, $task) = array_pad(explode('::', $task), 2, null);
if ($task === null) {
$task = $module;
$module = false;
}
if ($module) {
try {
\Module::load($module);
$path = \Module::exists($module);
\Finder::instance()->add_path($path);
} catch (\FuelException $e) {
throw new Exception(sprintf('Module "%s" does not exist.', $module));
}
}
// Just call and run() or did they have a specific method in mind?
list($task, $method) = array_pad(explode(':', $task), 2, 'run');
// Find the task
if (!($file = \Finder::search('tasks', $task))) {
$files = \Finder::instance()->list_files('tasks');
$possibilities = array();
foreach ($files as $file) {
$possible_task = pathinfo($file, \PATHINFO_FILENAME);
$difference = levenshtein($possible_task, $task);
$possibilities[$difference] = $possible_task;
}
ksort($possibilities);
if ($possibilities and current($possibilities) <= 5) {
throw new Exception(sprintf('Task "%s" does not exist. Did you mean "%s"?', $task, current($possibilities)));
} else {
throw new Exception(sprintf('Task "%s" does not exist.', $task));
}
return;
}
require_once $file;
$task = '\\Fuel\\Tasks\\' . ucfirst($task);
$new_task = new $task();
// The help option has been called, so call help instead
if ((\Cli::option('help') or $method == 'help') and is_callable(array($new_task, 'help'))) {
$method = 'help';
} else {
// if the task has an init method, call it now
is_callable($task . '::_init') and $task::_init();
}
if ($return = call_fuel_func_array(array($new_task, $method), $args)) {
\Cli::write($return);
}
}
示例7: hookCntrlrErrorOutput
/**
* hook: 'cntrlr_error_output'
* Provides 'Wiki like' functionaility for the Page module
*
* @param int $statusCode
* @param string $output
* @return string
*/
public function hookCntrlrErrorOutput($statusCode, $output)
{
if ($statusCode == 404 && Module::exists('page') && !Module::isDisabled('page') && $this->_acl->checkMulti(array('page_manage', 'aliases_add'), ACL::_MULTI_ALL)) {
$alias = $this->_router->getRequestPath();
if (trim($alias)) {
$msgStr = t('This page can be <a href="%1$s">created</a> with an alias of <strong>"%2$s"</strong>, simply <a href="%1$s">add this page</a> now.', _PROJECT_ID . '-page');
$output .= '<h3>' . t('Create this Page', _PROJECT_ID . '-page') . '</h3>';
$output .= sprintf('<p>' . $msgStr . '</p>', $this->_router->makeUrl('page', 'config', 'add', null, array('qe' => 'true', 'alias' => base64_encode($alias))), zula_htmlspecialchars($alias));
}
}
return $output;
}
示例8: before
public function before()
{
parent::before();
$this->_upgrade = new \Upgrade();
if (Module::exists('whmcs')) {
Module::load('whmcs');
if (\Whmcs\Whmcs::route()) {
$data = array();
return Response::forge(View::forge('whmcs/route', $data));
}
}
}
示例9: actionAccountMemberEditAccount
public function actionAccountMemberEditAccount($account_id = '', $args = '')
{
$testmod_path = \Module::exists('testmod');
$log_file_name = 'member-edit-account.txt';
$log_file_path = $testmod_path . $log_file_name;
// delete if exists.
if (\File::exists($log_file_path) && !is_writable($log_file_path)) {
return false;
} elseif (\File::exists($log_file_path) && is_writable($log_file_path)) {
\File::delete($log_file_path);
}
\File::create($testmod_path, $log_file_name, 'Member has edit to made changed their account. Account id = ' . $account_id . '. Arguments = ' . json_encode($args));
return true;
}
示例10: find_file
/**
* find view file<br>
* this method that extends fuelphp core theme is for re-arrange priority of theme and views.
*
* @param string $view
* @param string $themes
* @return string
*/
protected function find_file($view, $themes = null)
{
if ($themes === null) {
$themes = array($this->active, $this->fallback);
}
// determine the path prefix and optionally the module path
$path_prefix = '';
$module_path = null;
if ($this->config['use_modules'] and class_exists('Request', false) and $request = \Request::active() and $module = $request->module) {
// we're using module name prefixing
$path_prefix = $module . DS;
// and modules are in a separate path
is_string($this->config['use_modules']) and $path_prefix = trim($this->config['use_modules'], '\\/') . DS . $path_prefix;
// do we need to check the module too?
$this->config['use_modules'] === true and $module_path = \Module::exists($module) . 'themes' . DS;
}
foreach ($themes as $theme) {
$ext = pathinfo($view, PATHINFO_EXTENSION) ? '.' . pathinfo($view, PATHINFO_EXTENSION) : $this->config['view_ext'];
$file = (pathinfo($view, PATHINFO_DIRNAME) ? str_replace(array('/', DS), DS, pathinfo($view, PATHINFO_DIRNAME)) . DS : '') . pathinfo($view, PATHINFO_FILENAME);
if (empty($theme['find_file'])) {
if ($module_path and !empty($theme['name']) and is_file($path = $module_path . $theme['name'] . DS . $file . $ext)) {
// if use_modules is true then this $path will be /www/root/modules/<module name>/themes/<theme name>/<$view>.php
return $path;
} elseif (is_file($path = $theme['path'] . $path_prefix . $file . $ext)) {
// if use_modules is true then $path will be /www/root/<theme path>/<theme name>/<module name>/<$view>.php
// if use_modules is 'modules' then $path will be /www/root/<theme path>/<theme name>/modules/<module name>/<$view>.php
return $path;
} elseif (is_file($path = \Module::exists($module) . 'views' . DS . $file . $ext)) {
/**
* this condition was added by Vee W.
* look directly in modules/module_name/views. this $path will be /www/root/<modules path>/<module name>/views/<$view>.php
*
* @author Vee W.
*/
return $path;
} elseif (is_file($path = $theme['path'] . $file . $ext)) {
// this will not look into module name anymore. $path will be /www/root/<theme path>/<theme name>/<$view>.php
return $path;
}
} else {
if ($path = \Finder::search($theme['path'] . $path_prefix, $file, $ext)) {
return $path;
}
}
}
// not found, return the viewname to fall back to the standard View processing
return $view;
}
示例11: action_index
/**
* Load every call to the API with this method.
*
* @return void
* @access public
*/
public function action_index()
{
// Profile the loader
\Profiler::mark('Start of loader\'s action_index() function');
\Profiler::mark_memory($this, 'Start of loader\'s action_index() function');
// Make sure we aren't processing crap.
if (in_array($this->format, array('csv', 'php', 'serialize'))) {
$this->format = 'json';
}
// For some reason this value is quoted when set to html.
if (\Input::post('format') === '"html"') {
$this->format = 'html';
}
// Cleanse the session to keep things stable.
\Session::destroy();
// For error handling
\Session::set('response_format', $this->format);
// External error processing through Apache
if (\Uri::segment(1) === 'error' && is_numeric(\Uri::segment(2)) && strlen(\Uri::segment(2)) === 3) {
return $this->response(\Utility::format_error(\Uri::segment(2)));
}
// /loader/index/error/404 style (Due to routing)
if (substr_count(\Uri::current(), 'loader/index/error') === 1 && is_numeric(\Uri::segment(4)) && strlen(\Uri::segment(4)) === 3) {
return $this->response(\Utility::format_error(\Uri::segment(4)));
}
// We need a version number
if (empty(\Uri::segment(1)) || \Module::exists(\Uri::segment(1)) === false) {
$error_data = \Utility::format_error(400, \Err::BAD_OR_NO_VERSION, \Lang::get('errors.bad_version'));
return $this->response($error_data, 400);
}
// We need a request.
if (empty(\Input::post()) || \Input::method() !== 'POST') {
$error_data = \Utility::format_error(405, null, \Lang::get('errors.no_request'));
return $this->response($error_data, 405);
}
// Pass the request to the proper API version request handler. (Module)
if (!empty(\Input::post())) {
\Module::load(\Uri::segment(1));
$response = \Request::forge(\Uri::segment(1) . '/index', false)->execute()->response->body;
// HTML only Data Calls
if (is_string($response)) {
return $this->response($response, 200);
}
return $this->response($response[0], $response[1]);
}
}
示例12: action_index
public function action_index()
{
//$testModel = Model_Sales_Disposition::test();
/*
if (\Reports\Query::forge(\Reports\Query::LOAD, 3)->isComplete())
{
print_r('complete');
}
*/
// Load the required data module
if (!\Module::loaded('data') && \Module::exists('data')) {
\Module::load('data');
} else {
throw new \Exception("Data Module not found!");
}
$impData = \Data\Import::forge(\Data\Import::COPY, 1);
$this->template->title = 'Example Page';
$this->template->content = "hello";
}
示例13: run
/**
* Called by: php oil r movescaffoldtomodule
* Moves scaffold files to module.
*/
public function run($args = NULL)
{
/* We handle here options:
* * scaffold alias s: name of the scaffold to move
* * module alias m: module to move the scaffold into
* * force alias f: do we override existing files ?
*/
$scaffold = \Cli::option('scaffold', \Cli::option('s'));
$module = \Cli::option('module', \Cli::option('m'));
static::$force = \Cli::option('force', \Cli::option('f', false));
// Checking if the scaffold and module options are
// defined
if (is_null($scaffold) || is_null($module)) {
\Cli::error('Some parameters are missing.');
\Cli::error('Ex: php oil r moveScaffoldToModule' . ' -scaffold=category -module=blog');
return;
}
$module_path = \Module::exists($module);
// Is the module found ?
if ($module_path == null) {
\Cli::error('The specified module doesn\'t exists!');
return;
}
// Now processing each scaffold file / folders
foreach (static::$files_to_move as $item) {
$path = str_replace('(:scaffold)', $scaffold, $item['path']);
if (file_exists(APPPATH . $path)) {
/*
* As each file type must be processed
* differently, a different method is called
* depending on the type. For instance, if
* the file type is controller, we will call
* the process_controller method.
*/
static::{'process_' . $item['type']}($path, $module, $module_path);
}
}
// Processing migration as it is a special cases.
static::process_migration($scaffold, $module, $module_path);
}
示例14: exit
break;
////////////////////////////
//模块升级
////////////////////////////
//模块升级
case 'upgrade':
//通信已关闭
if ($connect == 'off') {
exit(serialize(array('return' => 'connect', 'connect' => $connect)));
}
//缺少必要参数
if (!$command['appid'] || !$command['package']) {
exit(serialize(array('return' => 'argument', 'appid' => $command['appid'], 'package' => $command['package'])));
}
//无效模块
if (Module::exists($command['appid']) === FALSE) {
exit(serialize(array('return' => 'invalid', 'appid' => $command['appid'])));
}
//测试读写权限
$status = Cloud::valid_perm($module);
if (count($status)) {
exit(serialize(array('return' => 'permission', 'catalog' => $status)));
}
//升级模块
$status = Cloud::upgrade_module($command['package'], $command['hash'], $command['appid'], $command['option']['upgrade']['ignore']);
//升级成功
if ($status > 0) {
//执行升级脚本
Module::upgrade($command['appid']);
//缓存模块
Module::search();
示例15: __call
/**
* catches requested method call and runs as needed
*
* @param string name of the method to run
* @param string any additional method arguments (not used here!)
*/
public function __call($name, $args)
{
// set method name
$name = '_' . $name;
// make sure the called name exists
if (!method_exists(get_called_class(), $name)) {
return static::help();
}
// run app (default) migrations if default is true
if (static::$default) {
static::$name('default', 'app');
}
// run migrations on all specified modules
foreach (static::$modules as $module) {
// check if the module exists
if (!\Module::exists($module)) {
\Cli::write('Requested module "' . $module . '" does not exist!', 'light_red');
} else {
// run the migration
static::$name($module, 'module');
}
}
// run migrations on all specified packages
foreach (static::$packages as $package) {
// check if the module exists
if (!\Package::exists($package)) {
\Cli::write('Requested package "' . $package . '" does not exist!', 'light_red');
} else {
static::$name($package, 'package');
}
}
}