当前位置: 首页>>代码示例>>PHP>>正文


PHP Bundle::parse方法代码示例

本文整理汇总了PHP中Laravel\Bundle::parse方法的典型用法代码示例。如果您正苦于以下问题:PHP Bundle::parse方法的具体用法?PHP Bundle::parse怎么用?PHP Bundle::parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Laravel\Bundle的用法示例。


在下文中一共展示了Bundle::parse方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: make

 /**
  * Create a new Doctrine migration.
  *
  * @param  array  $arguments
  * @return void
  */
 public function make($arguments)
 {
     if (count($arguments) == 0) {
         throw new \Exception("I need to know what to name the migration.");
     }
     list($bundle, $migration) = Bundle::parse($arguments[0]);
     // The migration path is prefixed with the date timestamp, which
     // is a better way of ordering migrations than a simple integer
     // incrementation, since developers may start working on the
     // next migration at the same time unknowingly.
     $prefix = date('Y_m_d_His');
     $path = Bundle::path($bundle) . 'migrations' . DS;
     // If the migration directory does not exist for the bundle,
     // we will create the directory so there aren't errors when
     // when we try to write the migration file.
     if (!is_dir($path)) {
         mkdir($path);
     }
     $file = $path . $prefix . '_' . $migration . EXT;
     File::put($file, $this->stub($bundle, $migration));
     echo "Great! New migration created!";
     // Once the migration has been created, we'll return the
     // migration file name so it can be used by the task
     // consumer if necessary for futher work.
     return $file;
 }
开发者ID:SerdarSanri,项目名称:doctrine-bundle,代码行数:32,代码来源:migrate.php

示例2: parse

 /**
  * Parse the task name to extract the bundle, task, and method.
  *
  * @param  string  $task
  * @return array
  */
 protected static function parse($task)
 {
     list($bundle, $task) = Bundle::parse($task);
     // Extract the task method from the task string. Methods are called
     // on tasks by separating the task and method with a single colon.
     // If no task is specified, "run" is used as the default.
     if (str_contains($task, ':')) {
         list($task, $method) = explode(':', $task);
     } else {
         $method = 'run';
     }
     return array($bundle, $task, $method);
 }
开发者ID:richthegeek,项目名称:Sasshare,代码行数:19,代码来源:command.php

示例3: call

 /**
  * Call an action method on a controller.
  *
  * <code>
  *		// Call the "show" method on the "user" controller
  *		$response = Controller::call('user@show');
  *
  *		// Call the "user/admin" controller and pass parameters
  *		$response = Controller::call('user.admin@profile', array($username));
  * </code>
  *
  * @param  string    $destination
  * @param  array     $parameters
  * @return Response
  */
 public static function call($destination, $parameters = array())
 {
     static::references($destination, $parameters);
     list($bundle, $destination) = Bundle::parse($destination);
     // We will always start the bundle, just in case the developer is pointing
     // a route to another bundle. This allows us to lazy load the bundle and
     // improve speed since the bundle is not loaded on every request.
     Bundle::start($bundle);
     list($controller, $method) = explode('@', $destination);
     $controller = static::resolve($bundle, $controller);
     // If the controller could not be resolved, we're out of options and
     // will return the 404 error response. If we found the controller,
     // we can execute the requested method on the instance.
     if (is_null($controller)) {
         return Event::first('404');
     }
     return $controller->execute($method, $parameters);
 }
开发者ID:bamper,项目名称:laravel.com,代码行数:33,代码来源:controller.php

示例4: 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, '/');
 }
开发者ID:ibrarturi,项目名称:laravel-tutorial,代码行数:23,代码来源:url.php

示例5: 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;
 }
开发者ID:Shahriar1824,项目名称:laravel-tutorial,代码行数:20,代码来源:view.php

示例6: controller

 /**
  * Register a controller with the router.
  *
  * @param  string|array  $controllers
  * @param  string|array  $defaults
  * @param  bool          $https
  * @return void
  */
 public static function controller($controllers, $defaults = 'index', $https = null)
 {
     foreach ((array) $controllers as $identifier) {
         list($bundle, $controller) = Bundle::parse($identifier);
         // First we need to replace the dots with slashes in the controller name
         // so that it is in directory format. The dots allow the developer to use
         // a cleaner syntax when specifying the controller. We will also grab the
         // root URI for the controller's bundle.
         $controller = str_replace('.', '/', $controller);
         $root = Bundle::option($bundle, 'handles');
         // If the controller is a "home" controller, we'll need to also build an
         // index method route for the controller. We'll remove "home" from the
         // route root and setup a route to point to the index method.
         if (ends_with($controller, 'home')) {
             static::root($identifier, $controller, $root);
         }
         // The number of method arguments allowed for a controller is set by a
         // "segments" constant on this class which allows for the developer to
         // increase or decrease the limit on method arguments.
         $wildcards = static::repeat('(:any?)', static::$segments);
         // Once we have the path and root URI we can build a simple route for
         // the controller that should handle a conventional controller route
         // setup of controller/method/segment/segment, etc.
         $pattern = trim("{$root}/{$controller}/{$wildcards}", '/');
         // Finally we can build the "uses" clause and the attributes for the
         // controller route and register it with the router with a wildcard
         // method so it is available on every request method.
         $uses = "{$identifier}@(:1)";
         $attributes = compact('uses', 'defaults', 'https');
         static::register('*', $pattern, $attributes);
     }
 }
开发者ID:shawon922,项目名称:LaravelBackboneTodoMVC,代码行数:40,代码来源:router.php

示例7: call

 /**
  * Call an action method on a controller.
  *
  * <code>
  *		// Call the "show" method on the "user" controller
  *		$response = Controller::call('user@show');
  *
  *		// Call the "user/admin" controller and pass parameters
  *		$response = Controller::call('user.admin@profile', array($username));
  * </code>
  *
  * @param  string    $destination
  * @param  array     $parameters
  * @return Response
  */
 public static function call($destination, $parameters = array())
 {
     static::references($destination, $parameters);
     list($bundle, $destination) = Bundle::parse($destination);
     // We will always start the bundle, just in case the developer is pointing
     // a route to another bundle. This allows us to lazy load the bundle and
     // improve speed since the bundle is not loaded on every request.
     Bundle::start($bundle);
     list($name, $method) = explode('@', $destination);
     $controller = static::resolve($bundle, $name);
     // For convenience we will set the current controller and action on the
     // Request's route instance so they can be easily accessed from the
     // application. This is sometimes useful for dynamic situations.
     if (!is_null($route = Request::route())) {
         $route->controller = $name;
         $route->controller_action = $method;
     }
     // If the controller could not be resolved, we're out of options and
     // will return the 404 error response. If we found the controller,
     // we can execute the requested method on the instance.
     if (is_null($controller)) {
         return Event::first('404');
     }
     return $controller->execute($method, $parameters);
 }
开发者ID:gigikiri,项目名称:masjid-l3,代码行数:40,代码来源:controller.php

示例8: parse

 /**
  * Parse the path to the form or page
  * 
  * @param string $name
  * @param string $type
  * 
  * @return array($file,$class_name,$method)
  */
 protected static function parse($name, $type)
 {
     list($path, $method) = explode('@', static::$modules[$type][$name]);
     list($bundle, $path) = Bundle::parse($path);
     $file = Bundle::path($bundle) . Str::plural($type) . DS . str_replace('.', DS, $path) . EXT;
     $class_name = static::format($bundle, $path, $type);
     return array($file, $class_name, $method);
 }
开发者ID:reith2004,项目名称:components,代码行数:16,代码来源:module.php

示例9: path

 /**
  * Get the path to a given view on disk.
  *
  * @param  string  $view
  * @return string
  */
 protected function path($view)
 {
     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::first(static::loader, array($bundle, $view));
     if (!is_null($path)) {
         return $path;
     }
     throw new \Exception("View [{$view}] doesn't exist.");
 }
开发者ID:victoroliveira1605,项目名称:Laravel-Bootstrap,代码行数:19,代码来源:view.php

示例10: controller

 public static function controller($controllers, $defaults = 'index', $https = null)
 {
     foreach ((array) $controllers as $identifier) {
         list($bundle, $controller) = Bundle::parse($identifier);
         $controller = str_replace('.', '/', $controller);
         $root = Bundle::option($bundle, 'handles');
         if (ends_with($controller, 'home')) {
             static::root($identifier, $controller, $root);
         }
         $wildcards = static::repeat('(:any?)', static::$segments);
         $pattern = trim("{$root}/{$controller}/{$wildcards}", '/');
         $uses = "{$identifier}@(:1)";
         $attributes = compact('uses', 'defaults', 'https');
         static::register('*', $pattern, $attributes);
     }
 }
开发者ID:laravelbook,项目名称:framework3,代码行数:16,代码来源:laravel_lite.php

示例11: convention

 protected static function convention($action, $parameters)
 {
     list($bundle, $action) = Bundle::parse($action);
     $bundle = Bundle::get($bundle);
     $root = $bundle['handles'] ?: '';
     $parameters = implode('/', $parameters);
     $uri = $root . '/' . str_replace(array('.', '@'), '/', $action);
     $uri = static::to(str_finish($uri, '/') . $parameters);
     return trim($uri, '/');
 }
开发者ID:laravelbook,项目名称:framework3,代码行数:10,代码来源:laravel_lite.php


注:本文中的Laravel\Bundle::parse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。