本文整理汇总了PHP中Laravel\Bundle::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP Bundle::exists方法的具体用法?PHP Bundle::exists怎么用?PHP Bundle::exists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Laravel\Bundle
的用法示例。
在下文中一共展示了Bundle::exists方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: upgrade
/**
* Upgrade the given bundles for the application.
*
* @param array $bundles
* @return void
*/
public function upgrade($bundles)
{
if (count($bundles) == 0) {
$bundles = Bundle::names();
}
foreach ($bundles as $name) {
if (!Bundle::exists($name)) {
echo "Bundle [{$name}] is not installed!";
continue;
}
// First we want to retrieve the information for the bundle, such as
// where it is currently installed. This will allow us to upgrade
// the bundle into it's current installation path.
$location = Bundle::path($name);
// If the bundle exists, we will grab the data about the bundle from
// the API so we can make the right bundle provider for the bundle,
// since we don't know the provider used to install.
$response = $this->retrieve($name);
if ($response['status'] == 'not-found') {
continue;
}
// Once we have the bundle information from the API, we'll simply
// recursively delete the bundle and then re-download it using
// the correct provider assigned to the bundle.
File::rmdir($location);
$this->download($response['bundle'], $location);
echo "Bundle [{$name}] has been upgraded!" . PHP_EOL;
}
}
示例2: bundle
/**
* Generate documentation for a given bundles. If no bundles are provided
* documentation will be generated for all registered bundles.
*
* @param array $bundles
* @return void
*/
public function bundle(array $bundles = array())
{
// If no bundles are provided documentation will be generated for all
// registered bundles.
if (count($bundles) === 0) {
$bundles = Bundle::names();
}
// Remove any bundles that have not been registered, and give a
// warning for each one we come across.
$bundles = array_filter($bundles, function ($name) {
if (!Bundle::exists($name)) {
if ($name == DEFAULT_BUNDLE) {
return true;
}
echo "Bundle [{$name}] is not registered.", PHP_EOL;
return false;
}
return true;
});
// If there are no registered bundles then exit with a message
if (count($bundles) === 0) {
echo PHP_EOL, "Please register your bundles and try again.", PHP_EOL;
return;
}
// Get the options
$options = $this->config(array_map(array('Bundle', 'path'), $bundles));
// Run ApiGen
$this->apigen($options);
}
示例3: unpublish
/**
* Delete a bundle's assets from the public directory
*
* @param string $bundle
* @return void
*/
public function unpublish($bundle)
{
if (!Bundle::exists($bundle)) {
echo "Bundle [{$bundle}] is not registered.";
return;
}
File::rmdir(path('public') . 'bundles' . DS . $bundle);
echo "Assets deleted for bundle [{$bundle}]." . PHP_EOL;
}
示例4: publish
/**
* Publish a bundle's assets to the public directory.
*
* @param string $bundle
* @return void
*/
public function publish($bundle)
{
if (!Bundle::exists($bundle)) {
echo "Bundle [{$bundle}] is not registered.";
return;
}
$path = Bundle::path($bundle);
$this->move($path . 'public', path('public') . 'bundles' . DS . $bundle);
echo "Assets published for bundle [{$bundle}]." . PHP_EOL;
}
示例5: run
/**
* Run a CLI task with the given arguments.
*
* <code>
* // Call the migrate artisan task
* Command::run(array('migrate'));
*
* // Call the migrate task with some arguments
* Command::run(array('migrate:rollback', 'bundle-name'))
* </code>
*
* @param array $arguments
* @return void
*/
public static function run($arguments = array())
{
static::validate($arguments);
list($bundle, $task, $method) = static::parse($arguments[0]);
// If the task exists within a bundle, we will start the bundle so that any
// dependencies can be registered in the application IoC container. If the
// task is registered in the container, we'll resolve it.
if (Bundle::exists($bundle)) {
Bundle::start($bundle);
}
$task = static::resolve($bundle, $task);
// Once the bundle has been resolved, we'll make sure we could actually
// find that task, and then verify that the method exists on the task
// so we can successfully call it without a problem.
if (is_null($task)) {
throw new \Exception("Sorry, I can't find that task.");
}
if (is_callable(array($task, $method))) {
$task->{$method}(array_slice($arguments, 1));
} else {
throw new \Exception("Sorry, I can't find that method!");
}
}
示例6: __construct
/**
* Create a new module instance.
*
* <code>
* // Create a new module instance
* $module = new Modules\Module('registration');
*
* // Create a new module instance with a path
* $module = new Modules\Module('registration', 'registration/extended');
*
* // Create a new module instance with a full path
* $module = new Modules\Module('registration', 'path: /var/www/project/registration');
* </code>
*
* @param string $module
* @param string $path
* @return void
*/
public function __construct($module_slug, $path = null)
{
$this->slug = $module_slug;
$ins = \Laravel\Config::get('installed_modules.' . $module_slug);
$this->installed = isset($ins) and !empty($ins) ? true : false;
$this->enabled = \Laravel\Bundle::exists($this->slug);
$this->installer = Installer::make($module_slug);
// if path starts with "path: "
// its a custom path
if (!isset($path)) {
$this->path = path('bundle') . $this->slug . DS;
} else {
if (starts_with($path, 'path: ')) {
$this->path = substr($path, 6);
} else {
// sets the path to modules
// folder + path
// module with different folder name?
$this->path = path('bundle') . $path;
}
}
// If a session driver has been specified, we will bind an instance of the
// module error message container. If an error instance
// exists in the session, we will use that instance.
if (!isset($this->errors)) {
if (Session::started() and Session::has('errors')) {
$this->errors = Session::get('errors');
} else {
$this->errors = new Messages();
}
}
}