本文整理汇总了PHP中Laravel\Bundle类的典型用法代码示例。如果您正苦于以下问题:PHP Bundle类的具体用法?PHP Bundle怎么用?PHP Bundle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Bundle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: globSeedFiles
/**
* Get all of the files at a given path.
*
* @param string $path
* @return array
*/
protected function globSeedFiles()
{
if (isset($this->seedFiles)) {
return $this->seedFiles;
}
// If the seeds haven't been read before, we will glob the directories and sort
// them alphabetically just in case the developer is using numbers to make
// the seed run in a certain order based on their database design needs.
$folders = array(path('app') . 'seeds' . DS);
foreach (Bundle::$bundles as $bundle) {
$folders[] = Bundle::path($bundle['location']) . 'seeds' . DS;
}
$files = array();
foreach ($folders as $folder) {
$files = array_merge($files, glob($folder . '*.php'));
}
if (false !== $this->getParameter('except')) {
$exclude = explode(',', $this->getParameter('except'));
foreach ($files as $key => $file) {
if (in_array(pathinfo($file, PATHINFO_FILENAME), $exclude)) {
unset($files[$key]);
}
}
}
sort($files);
return $this->seedFiles = $files;
}
示例3: get_files
/**
* Get files for comparision editing
*
* @param string $name
* @param string $location
* @param string $translation
* @return array
*/
public static function get_files($name, $location, $translation)
{
$path = \Laravel\Bundle::path($location);
if (!is_file($path . 'language/' . $translation . '/' . $name . '.php')) {
return null;
}
$language['from'] = (require $path . 'language/' . \Laravel\Config::get('language-builder::builder.base_lang') . '/' . $name . '.php');
$language['to'] = (require $path . 'language/' . $translation . '/' . $name . '.php');
return $language;
}
示例4: stub
/**
* Get the stub migration with the proper class name.
*
* @param string $bundle
* @param string $migration
* @return string
*/
protected function stub($bundle, $migration)
{
$stub = File::get(Bundle::path('doctrine') . 'migration_stub' . EXT);
$prefix = Bundle::class_prefix($bundle);
// The class name is formatted simialrly to tasks and controllers,
// where the bundle name is prefixed to the class if it is not in
// the default "application" bundle.
$class = $prefix . Str::classify($migration);
return str_replace('{{class}}', $class, $stub);
}
示例5: path
/**
* Get the path to a view on disk.
*
* @param $view
*
* @return string
* @throws \Exception
*/
protected function path($view)
{
$view = str_replace('.', '/', $view);
$this->bundle_root = $root = Bundle::path(Bundle::name($view)) . 'views';
$path = $root . DS . Bundle::element($view) . $this->template_ext;
if (file_exists($path)) {
$this->template = $view . $this->template_ext;
return $path;
}
throw new \Exception("View [{$view}] does not exist.");
}
示例6: bundles
/**
* Load all the bundles with language files and get their paths
*
* @param string $lang
* @return array
*/
public static function bundles($lang = null)
{
$folders = array();
// Get the bundle languages
if ($bundles = \Laravel\Bundle::all()) {
foreach ($bundles as $bundle) {
if (is_dir(\Laravel\Bundle::path($bundle['location']) . '/language/' . $lang)) {
$folders[] = array('path' => \Laravel\Bundle::path($bundle['location']) . 'language/', 'name' => $bundle);
}
}
}
return $folders;
}
示例7: bundle
/**
* Run the tests for a given bundle.
*
* @param array $bundles
* @return void
*/
public function bundle($bundles = array())
{
if (count($bundles) == 0) {
$bundles = Bundle::names();
}
foreach ($bundles as $bundle) {
// To run PHPUnit for the application, bundles, and the framework
// from one task, we'll dynamically stub PHPUnit.xml files via
// the task and point the test suite to the correct directory
// based on what was requested.
if (is_dir($path = Bundle::path($bundle) . 'tests')) {
$this->stub($path);
$this->test();
}
}
}
示例8: attribute
/**
* Get the displayable name for a given attribute.
*
* @param string $attribute
* @return string
*/
protected function attribute($attribute)
{
$bundle = Bundle::prefix($this->bundle);
// More reader friendly versions of the attribute names may be stored
// in the validation language file, allowing a more readable version
// of the attribute name to be used in the message.
//
// If no language line has been specified for the attribute, all of
// the underscores will be removed from the attribute name and that
// will be used as the attribtue name.
$line = "{$bundle}validation.attributes.{$attribute}";
$display = Lang::line($line)->get($this->language);
return is_null($display) ? str_replace('_', ' ', $attribute) : $display;
}
示例9: isset
@if(isset($modules) and !empty($modules))
<?php
$installed_modules = Config::get('installed_modules');
?>
@foreach($modules as $module)
<tr id="{{$module->slug}}">
<?php
$bundle = \Laravel\Bundle::get($module->slug);
?>
<?php
$handles = isset($bundle['handles']) ? 1 : 0;
?>
@if( isset($installed_modules[$module->slug]) and $module->enabled == true and $handles == 1)
<td class="collapse"><a href="{{ URL::base().'/'.ADM_URI.'/'.$module->slug }}">{{ $module->name }}</a></td>
@else
<td class="collapse">{{ $module->name }}</td>
@endif
<td>{{ $module->description }}<p>{{ $module->requirements_to_string() }}</p></td>
<td>{{ $module->version }}</td>
<td class="action-buttons-{{$module->slug}}">
@if($module->enabled == true and isset($installed_modules[$module->slug]))
<a data-verb="PUT" data-module="modules" data-title="{{ Lang::line('modules::lang.Are you sure you wanto to disable ":module_name"?', array('module_name' => $module->name))->get(ADM_LANG) }}" class="confirm btn btn-mini" href="{{ URL::base().'/'.ADM_URI.'/' }}modules/disable/{{ $module->slug }}"><i class="icon-minus"></i> {{ Lang::line('modules::lang.disable')->get(ADM_LANG) }}</a>
@endif
@if( $module->enabled == false and isset($installed_modules[$module->slug]) )
<a data-verb="PUT" data-module="modules" data-title="{{ Lang::line('modules::lang.Are you sure you wanto to enable ":module_name"?', array('module_name' => $module->name))->get(ADM_LANG) }}" class="confirm btn btn-mini btn-success" href="{{ URL::base().'/'.ADM_URI.'/' }}modules/enable/{{ $module->slug }}"><i class="icon-plus"></i> {{ Lang::line('modules::lang.enable')->get(ADM_LANG) }}</a>
<a data-module="modules" data-verb="DELETE" data-title="{{ Lang::line('modules::lang.Are you sure you wanto to uninstall ":module_name"?', array('module_name' => $module->name))->get(ADM_LANG) }}" class="btn btn-mini btn-danger confirm" href="{{ URL::base().'/'.ADM_URI.'/' }}modules/{{ $module->slug }}"><i class="icon-remove icon-white"></i> {{ Lang::line('modules::lang.Uninstall')->get(ADM_LANG) }}</a>
示例10: autoloads
/**
* Register the auto-loading configuration for a bundle.
*
* @param string $bundle
* @param array $config
* @return void
*/
protected static function autoloads($bundle, $config)
{
$path = rtrim(Bundle::path($bundle), DS);
foreach ($config['autoloads'] as $type => $mappings) {
// When registering each type of mapping we'll replace the (:bundle)
// place-holder with the path to the bundle's root directory, so
// the developer may dryly register the mappings.
$mappings = array_map(function ($mapping) use($path) {
return str_replace('(:bundle)', $path, $mapping);
}, $mappings);
// Once the mappings are formatted, we will call the Autoloader
// function matching the mapping type and pass in the array of
// mappings so they can be registered and used.
Autoloader::$type($mappings);
}
}
示例11: convention
/**
* Generate an action URI by convention.
*
* @param string $action
* @param array $parameters
* @return string
*/
protected static function convention($action, $parameters)
{
list($bundle, $action) = Bundle::parse($action);
$bundle = Bundle::get($bundle);
// If a bundle exists for the action, we will attempt to use it's "handles"
// clause as the root of the generated URL, as the bundle can only handle
// URIs that begin with that string and no others.
$root = $bundle['handles'] ?: '';
$parameters = implode('/', $parameters);
// We'll replace both dots and @ signs in the URI since both are used
// to specify the controller and action, and by convention should be
// translated into URI slashes for the URL.
$uri = $root . '/' . str_replace(array('.', '@'), '/', $action);
$uri = static::to(str_finish($uri, '/') . $parameters);
return trim($uri, '/');
}
示例12: exists
/**
* Determine if the given view exists.
*
* @param string $view
* @param boolean $return_path
* @return string|bool
*/
public static function exists($view, $return_path = false)
{
list($bundle, $view) = Bundle::parse($view);
$view = str_replace('.', '/', $view);
// We delegate the determination of view paths to the view loader event
// so that the developer is free to override and manage the loading
// of views in any way they see fit for their application.
$path = Event::until(static::loader, array($bundle, $view));
if (!is_null($path)) {
return $return_path ? $path : true;
}
return false;
}
示例13: attribute
/**
* Get the displayable name for a given attribute.
*
* @param string $attribute
* @return string
*/
protected function attribute($attribute)
{
$bundle = Bundle::prefix($this->bundle);
// More reader friendly versions of the attribute names may be stored
// in the validation language file, allowing a more readable version
// of the attribute name in the message.
$line = "{$bundle}validation.attributes.{$attribute}";
if (Lang::has($line, $this->language)) {
return Lang::line($line)->get($this->language);
} else {
return str_replace('_', ' ', $attribute);
}
}
示例14: __construct
/**
* Create a new HelpSpot Migration instance.
*
* @return void
*/
public function __construct()
{
Bundle::start('doctrine');
$this->em = IoC::resolve('doctrine::manager');
$this->sm = $this->em->getConnection()->getSchemaManager();
}
示例15: defined
<?php
namespace Laravel\CLI;
defined('DS') or die('No direct script access.');
use Laravel\Bundle;
use Laravel\Config;
use Laravel\Request;
/**
* Fire up the default bundle. This will ensure any dependencies that
* need to be registered in the IoC container are registered and that
* the auto-loader mappings are registered.
*/
Bundle::start(DEFAULT_BUNDLE);
/**
* The default database connection may be set by specifying a value
* for the "database" CLI option. This allows migrations to be run
* conveniently for a test or staging database.
*/
if (!is_null($database = get_cli_option('db'))) {
Config::set('database.default', $database);
}
/**
* We will register all of the Laravel provided tasks inside the IoC
* container so they can be resolved by the task class. This allows
* us to seamlessly add tasks to the CLI so that the Task class
* doesn't have to worry about how to resolve core tasks.
*/
require path('sys') . 'cli/dependencies' . EXT;
/**
* We will wrap the command execution in a try / catch block and