本文整理汇总了PHP中Bundle::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP Bundle::exists方法的具体用法?PHP Bundle::exists怎么用?PHP Bundle::exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bundle
的用法示例。
在下文中一共展示了Bundle::exists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_links_tree
/**
* Build a multi-array of parent > children.
*
* @return array An array representing the page tree.
*/
public function get_links_tree()
{
if (\Bundle::exists('pages')) {
$all_links = Link::with('page')->order_by('order', 'asc')->get(array('id', 'group_id', 'title', 'class'));
} else {
$all_links = Link::order_by('order', 'asc')->get(array('id', 'group_id', 'title', 'class'));
}
// First, re-index the array.
foreach ($all_links as $row) {
$pages[$row->id] = array('id' => $row->id, 'li_id' => 'link_', 'link_type' => $row->link_type, 'rel' => $row->navigation_group_id, 'parent_id' => $this->id, 'title' => $row->title, 'url' => $row->url, 'target' => $row->target, 'class' => $row->class);
}
unset($all_links);
// Build a multidimensional array of parent > children.
foreach ($pages as $row) {
if (array_key_exists($row['parent_id'], $pages)) {
// Add this page to the children array of the parent page.
$pages[$row['parent_id']]['children'][] =& $pages[$row['id']];
}
// This is a root page.
if ($row['parent_id'] == 0) {
$page_array[] =& $pages[$row['id']];
}
}
return $page_array;
}
示例2: group
public function group()
{
if (\Bundle::exists('groups')) {
return $this->belongs_to('Groups\\Model\\Group');
} else {
throw new \Exception('Groups module is not installed. To call users with group you must install the groups module.');
}
}
示例3: users
public function users()
{
if (\Bundle::exists('permissions')) {
return $this->has_many('Users\\Model\\User');
} else {
throw new \Exception('Permissions module is not installed. To call goups with users you must install the permissions module.');
}
}
示例4: get_new
public function get_new()
{
$this->data['section_bar_active'] = __('email::lang.Send Email')->get(ADM_LANG);
$this->data['groups_dropdown'] = null;
if (Bundle::exists('groups')) {
$this->data['groups_dropdown'] = Groups\Model\Group::all();
}
$this->data['email_templates'] = Email\Model\Template::all();
return $this->theme->render('email::email.new', $this->data);
}
示例5: __construct
public function __construct()
{
parent::__construct();
$this->filter('before', 'auth');
$this->filter('before', 'mwi.admin_controller_start', array($this));
// $this->filter('before', 'check_rule:admin');
$this->filter('before', 'csrf')->on('post');
$this->data['installed_and_active_modules'] = Modules\Model\Module::where('enabled', '=', 1)->get(array('name', 'menu'));
if (Bundle::exists('themes')) {
$this->theme->set_theme(Config::get('settings::core.backend_theme'), 'backend');
$this->theme->set_layout(Config::get('settings::core.backend_layout'), 'backend');
$this->theme->_theme_data = $this->data;
}
}
示例6: __construct
public function __construct()
{
parent::__construct();
$this->data['site_name'] = Config::get('settings::core.site_name');
$this->data['meta_title'] = '';
$this->data['meta_description'] = '';
$this->data['meta_keywords'] = '';
if (Bundle::exists('themes')) {
$this->theme = IoC::resolve('Theme');
}
// @TODO add fallback if themes module for
// some reason is not installed/enabled
$this->filter('before', 'mwi.base_controller_start', array($this));
}
示例7: __construct
function __construct()
{
parent::__construct();
if (Bundle::exists('themes')) {
$this->theme->set_theme(Config::get('settings::core.frontend_theme'));
$this->theme->set_layout(Config::get('settings::core.frontend_layout'));
}
$maintenance = Config::get('settings::core.site_maintenance');
if ($maintenance == 'yes') {
echo View::make('admin::frontend.maintenance');
die;
}
$this->filter('before', 'mwi.private_controller_start', array($this));
$this->filter('before', 'auth');
$this->filter('before', 'csrf')->on('post');
}
示例8: __construct
function __construct()
{
parent::__construct();
if (Bundle::exists('themes')) {
$this->theme->set_theme(Config::get('settings::core.frontend_theme', 'frontend'));
$this->theme->set_layout(Config::get('settings::core.frontend_layout'));
}
$maintenance = Config::get('settings::core.site_maintenance');
if ($maintenance == 'yes') {
$this->data['site_name'] = Config::get('settings::core.site_name');
echo $this->theme->render('admin::frontend.maintenance', $this->data);
die;
}
$this->filter('before', 'mwi.public_controller_start', array($this));
$this->filter('before', 'csrf')->on('post');
}
示例9: get_links
public function get_links()
{
$links_raw = array();
foreach ($this->links as $link) {
if ($this->passes(explode(',', $link->restricted_to), new Auth())) {
// Check the link type to set the wright url
$url = '#';
if ($link->link_type == 'url') {
$url = $link->url;
}
if ($link->link_type == 'uri') {
$url = $link->uri;
}
if ($link->link_type == 'module') {
$url = 'what put here';
}
if ($link->link_type == 'page') {
// If pages module is not installed
// the link_type should not be page
// lets test it
if (\Bundle::exists('pages')) {
if (!is_null($link->page)) {
$url = $link->page->slug;
} else {
$url = '404';
}
}
}
$links_raw[$link->id] = array('id' => $link->id, 'li_id' => 'link_', 'link_type' => $link->link_type, 'rel' => $this->id, 'parent_id' => $link->parent, 'title' => $link->title, 'url' => $url, 'target' => $link->target, 'class' => $link->class);
}
}
$links_result = array();
foreach ($links_raw as $link) {
if (array_key_exists($link['parent_id'], $links_raw)) {
// Add this page to the children array of the parent page.
$links_raw[$link['parent_id']]['children'][] =& $links_raw[$link['id']];
}
// This is a root page.
if ($link['parent_id'] == 0) {
$links_result[] =& $links_raw[$link['id']];
}
}
return $links_result;
}
示例10: load
/**
* Load the file corresponding to a given class.
*
* This method is registerd in the bootstrap file as an SPL auto-loader.
*
* @param string $class
* @return void
*/
public static function load($class)
{
// First, we will check to see if the class has been aliased. If it has,
// we will register the alias, which may cause the auto-loader to be
// called again for the "real" class name.
if (isset(static::$aliases[$class])) {
class_alias(static::$aliases[$class], $class);
} elseif (isset(static::$mappings[$class])) {
require static::$mappings[$class];
}
// If the class namespace is mapped to a directory, we will load the
// class using the PSR-0 standards from that directory; however, we
// will trim off the beginning of the namespace to account for
// the root of the mapped directory.
if (!is_null($info = static::namespaced($class))) {
$class = substr($class, strlen($info['namespace']));
return static::load_psr($class, $info['directory']);
} elseif (($slash = strpos($class, '\\')) !== false) {
$namespace = substr($class, 0, $slash);
// If the class is namespaced to an existing bundle and the bundle has
// not been started, we will start the bundle and attempt to load the
// class file again. If that fails, an error will be thrown by PHP.
//
// This allows bundle classes to be loaded by the auto-loader before
// their class mappings have actually been registered; however, it
// is up to the bundle developer to namespace their classes to
// match the name of their bundle.
if (Bundle::exists($namespace) and !Bundle::started($namespace)) {
Bundle::start(strtolower($namespace));
static::load($class);
}
}
// If the class is not maped and is not part of a bundle or a mapped
// namespace, we'll make a last ditch effort to load the class via
// the PSR-0 from one of the registered directories.
static::load_psr($class);
}
示例11: Error
<?php
if (!Bundle::exists('vane')) {
throw new Error('VaneMart requires Vane bundle installed.');
} else {
Bundle::start('vane');
Vane\aliasIn('VaneMart');
}
Squall\initEx('VaneMart');
Vane\overrideHTMLki('vanemart::', array('ns' => 'VaneMart', 'stickyFormHiddens' => array('back')));
require_once __DIR__ . DS . 'core.php';
require_once __DIR__ . DS . 'events.php';
Vane\Current::set(VaneMart\VANE_NS);
// More flexible autoloader for VaneMart flat class structure.
spl_autoload_register(function ($class) {
$base = $file = __DIR__ . DS . 'classes' . DS;
if (substr($class, 0, 9) === 'VaneMart\\') {
@(list($group, $rest) = explode('_', substr($class, 9), 2));
if (isset($rest)) {
$file .= strtolower($group) . DS . $rest;
} else {
$file .= is_file("{$file}{$group}.php") ? $group : 'model' . DS . substr($class, 9);
}
} else {
$file .= 'vendor' . DS . $class;
}
$file .= '.php';
is_file($file) and (include $file);
});
View::composer('vanemart::full', function ($view) {
$normAssets = function ($type) use($view) {
示例12: function
<?php
Autoloader::namespaces(array('Permissions\\Model' => Bundle::path('permissions') . 'models' . DS, 'Permissions' => Bundle::path('permissions') . 'libraries' . DS));
Route::filter('mwi.admin_controller_start', function ($controller) {
$permissions = new \Permissions\Check(\Request::route(), $controller);
if (!Bundle::exists('auth')) {
return;
}
// Fix route bundle if
// its an administration route
$uri = Request::route()->uri;
$uri_parts = explode('/', $uri);
// check if is set
// check if first part is administration uri
// check if is not only the dashboard http://site.com/[admin]
if (isset($uri_parts['0']) and $uri_parts['0'] = ADM_URI and count($uri_parts) > 1) {
unset($uri_parts['0']);
$uri = implode('/', $uri_parts);
Request::route()->bundle = Bundle::handles($uri);
$controller->bundle = Request::route()->bundle;
}
$result = $permissions::can(Auth::user());
if (isset($result)) {
if (!$result->is_allowed) {
if (Request::ajax()) {
return 'not permited';
} else {
return \Response::error('401', get_object_vars($result));
}
}
} else {
示例13: get_new
public function get_new($group_id)
{
if (Bundle::exists('pages')) {
$pages = Pages\Model\Page::where('status', '=', 'live')->get(array('id', 'title'));
} else {
$pages = null;
}
$modules = Modules\Model\Module::where('enabled', '=', 1)->where('is_frontend', '=', 1)->get(array('id', 'slug', 'name'));
$groups = Groups\Model\Group::all();
return View::make('navigation::backend.links.create', $this->data)->with('nav_group_id', $group_id)->with('modules', $modules)->with('pages', $pages)->with('groups', $groups);
}
示例14: array
<?php
namespace Vane;
\Bundle::$bundles['vane']['ignorePlarx'] = array('Str', 'HLEx', 'Log', 'Event', 'Validator');
if (!\Bundle::exists('plarx')) {
throw new Error('Vane requires Plarx bundle installed.');
} else {
\Bundle::start('plarx');
\Px\Plarx::supersede(__NAMESPACE__, \Bundle::option('vane', 'ignorePlarx'));
}
if (!\Bundle::exists('squall')) {
throw new Error('Vane requires Squall bundle installed.');
} else {
\Bundle::start('squall');
\Squall\initEx(__NAMESPACE__);
}
\Autoloader::namespaces(array(__NAMESPACE__ => __DIR__ . DS . 'classes'));
require_once __DIR__ . DS . 'core.php';
overrideHTMLki('vane::', __NAMESPACE__);
// vane::auth[:[!]perm[:[!]perm.2[...]]] [|filter:2 [|...]]
//
// This filter will always deny access for non-authorized users even if guest
// permissions allow for given features - this is so because protected controllers
// rely on current user being logged in.
\Route::filter('vane::auth', function ($feature_1 = null) {
$features = is_array($feature_1) ? $feature_1 : func_get_args();
$block = is_object(end($features)) ? array_pop($features) : null;
$user = \Auth::user();
if ($user and !$user instanceof UserInterface) {
$msg = "When using vane::auth filter object returned by Auth::user()" . " (" . get_class($user) . " here) must implement Vane\\UserInterface." . " This is not so - returned 403 for user {$user->id}.";
示例15: delete_destroy
public function delete_destroy($group_id)
{
if (!ctype_digit($group_id)) {
$this->data['message'] = __('groups::lang.Invalid id')->get(ADM_LANG);
$this->data['message_type'] = 'error';
return Redirect::back()->with($this->data);
}
if (Bundle::exists('permissions')) {
$group = Groups\Model\Group::with('permissions')->find($group_id);
} else {
$group = Groups\Model\Group::find($group_id);
}
if (!isset($group) or empty($group)) {
$this->data['message'] = __('groups::lang.Sorry cannot find group to delete')->get(ADM_LANG);
$this->data['message_type'] = 'error';
return Redirect::back()->with($this->data);
}
$users_group = Groups\Model\Group::where('slug', '=', 'users')->first();
// if there is users on this group
// set all users back to users group
if (isset($users_group) and isset($users_group->id)) {
$update = Users\Model\User::where('group_id', '=', $group->id)->update(array('group_id' => $users_group->id));
}
if (isset($group->permissions) and !empty($group->permissions)) {
$group->permissions()->delete();
}
$group->delete();
Event::fire('mwi.group_deleted', array($group));
$this->data['message'] = __('groups::lang.Group was successfully destroyed')->get(ADM_LANG);
$this->data['message_type'] = 'success';
return Redirect::to(ADM_URI . '/groups')->with($this->data);
}