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


PHP IoC类代码示例

本文整理汇总了PHP中IoC的典型用法代码示例。如果您正苦于以下问题:PHP IoC类的具体用法?PHP IoC怎么用?PHP IoC使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: is_postspage

function is_postspage()
{
    if ($itm = IoC::resolve('page')) {
        return $itm->id == Config::get('metadata.posts_page');
    }
    return false;
}
开发者ID:nathggns,项目名称:anchor-cms,代码行数:7,代码来源:helpers.php

示例2: page_status

function page_status()
{
    if ($itm = IoC::resolve('page')) {
        return $itm->status;
    }
    return '';
}
开发者ID:rubenvincenten,项目名称:anchor-site,代码行数:7,代码来源:pages.php

示例3: _isUnread

 private function _isUnread()
 {
     if (Auth::guest()) {
         return false;
     }
     $markAsReadAfter = value(Config::get('forums::forums.mark_as_read_after'));
     if (!IoC::registered('topicsview')) {
         IoC::singleton('topicsview', function () use($markAsReadAfter) {
             return Forumview::where('updated_at', '>=', date('Y-m-d H:i:s', $markAsReadAfter))->where('user_id', '=', Auth::user()->id)->lists('topic_id');
         });
     }
     $tv = IoC::resolve('topicsview');
     $nb = count($tv);
     $view = Forumtopic::where('forumcategory_id', '=', $this->id)->where('updated_at', '>=', date('Y-m-d H:i:s', $markAsReadAfter));
     if ($nb > 0) {
         $view = $view->where_not_in('id', $tv);
     }
     $view = $view->count();
     if ($nb == 0 && $view > 0) {
         return true;
     }
     if ($view > 0) {
         return true;
     }
     return false;
 }
开发者ID:marmaray,项目名称:OLD-laravel-France-website,代码行数:26,代码来源:forumcategory.php

示例4: parse

 private static function parse()
 {
     // get uri
     $uri = Request::uri();
     // lets log our initial uri
     Log::info('Requested URI: ' . $uri);
     // route definitions
     $routes = array();
     // posts host page
     if ($page = IoC::resolve('posts_page')) {
         $routes[$page->slug . '/(:any)'] = 'article/$1';
     }
     // fallback to 'admin'
     $admin_folder = Config::get('application.admin_folder', 'admin');
     // static routes
     $routes = array_merge($routes, array($admin_folder . '/(:any)/(:any)/(:any)' => 'admin/$1/$2/$3', $admin_folder . '/(:any)/(:any)' => 'admin/$1/$2', $admin_folder . '/(:any)' => 'admin/$1', $admin_folder => 'admin', 'search/(:any)' => 'search/$1', 'search' => 'search', 'rss' => 'rss', '(:any)' => 'page/$1'));
     // define wild-cards
     $search = array(':any', ':num');
     $replace = array('[0-9a-zA-Z~%\\.:_\\-]+', '[0-9]+');
     // parse routes
     foreach ($routes as $route => $translated) {
         // replace wildcards
         $route = str_replace($search, $replace, $route);
         // look for matches
         if (preg_match('#^' . $route . '#', $uri, $matches)) {
             // replace matched values
             foreach ($matches as $k => $match) {
                 $translated = str_replace('$' . $k, $match, $translated);
             }
             // return on first match
             return $translated;
         }
     }
     return $uri;
 }
开发者ID:nathggns,项目名称:anchor-cms,代码行数:35,代码来源:anchor.php

示例5: menu_active

function menu_active()
{
    if ($itm = IoC::resolve('menu_item')) {
        return $itm->active;
    }
    return '';
}
开发者ID:reqshark,项目名称:anchor-cms,代码行数:7,代码来源:menus.php

示例6: action_index

 public function action_index()
 {
     $markdown = IoC::resolve('markdown');
     $data['toc'] = $markdown->transform(File::get(VIEW_PATH . 'contents.md'));
     $data['default_contents'] = $markdown->transform(File::get(VIEW_PATH . 'start/install.md'));
     return View::make('home.index', $data);
 }
开发者ID:reith2004,项目名称:docs,代码行数:7,代码来源:home.php

示例7: testSendEmail

 /**
  * Test to send a real-world message
  *
  * @return void
  */
 public function testSendEmail()
 {
     require 'fixtures/message.php';
     $postmark = IoC::resolve('postmark');
     $return = $postmark->send(new Message('hello@yoozi.cn'));
     $this->assertTrue($return);
 }
开发者ID:SerdarSanri,项目名称:laravel-stampie,代码行数:12,代码来源:postmark.test.php

示例8: __get

 /**
  * 
  * @param string $name
  * @return object
  */
 public function __get($name)
 {
     self::$called_class = get_called_class();
     if (method_exists('\\system\\services\\SystemServiceRegistry', $name) || method_exists('\\application\\services\\AppServiceRegistry', $name)) {
         return IoC::resolve($name);
     }
 }
开发者ID:netprogs1,项目名称:yafop,代码行数:12,代码来源:ServiceLocator.php

示例9: comments_open

function comments_open()
{
    if ($itm = IoC::resolve('article')) {
        return $itm->comments ? true : false;
    }
    return false;
}
开发者ID:reqshark,项目名称:anchor-cms,代码行数:7,代码来源:comments.php

示例10: test_can_resolve_out_of_the_ioc_container

 public function test_can_resolve_out_of_the_ioc_container()
 {
     IoC::bind('foo', function () {
         return new Foo();
     });
     $this->assertInstanceOf('Foo', IoC::make('foo'));
 }
开发者ID:actank,项目名称:simple-di-container,代码行数:7,代码来源:IoCTest.php

示例11: post_review

 public function post_review()
 {
     $this->filter('before', 'jboardOnly');
     $input = Input::all();
     //grab our input
     $rules = array('decision' => 'required', 'denyreason' => 'required', 'initials' => 'required|alpha|min:2', 'amtreduce' => 'numeric', 'details' => 'required');
     //validation rules
     $validation = Validator::make($input, $rules);
     //let's run the validator
     if ($validation->fails()) {
         return Redirect::to('jboard/review/' . Input::get('ticketid'))->with_errors($validation);
     }
     //insert ruling into database
     Ruling::create(array('decision' => Input::get('decision'), 'denyreason' => Input::get('denyreason'), 'reasoning' => Input::get('details'), 'intials' => Input::get('initials'), 'CWID' => Input::get('cwid'), 'amtReduce' => Input::get('amtreduce'), 'ticketID' => Input::get('ticketid')));
     //let's close the ticket now
     $close = DB::table('tickets')->where('ticketID', '=', Input::get('ticketid'))->update(array('appealStatus' => '1'));
     return Redirect::to('jboard/')->with('alertMessage', 'Ruling submitted successfully.');
     DB::table('tickets')->where('ticketID', '=', Input::get('ticketid'))->update(array('appealStatus' => '1'));
     /////////////////////
     // Now we're going to email the appellant to let them know that their appeal has been reviewed.
     /////////////////////
     // Get the Swift Mailer instance
     $mailer = IoC::resolve('mailer');
     //set the appellant's email address using CWID
     $email = Input::get('cwid') . '@marist.edu';
     //set html body of email
     $body = "This autogenerated email is to let you know that your appeal has been reviewed and closed by the Justice Board. Please login to the Online Parking Appeal System at <a href='http://sga.marist.edu/parkingappeals/'>http://sga.marist.edu/parkingappeals/</a>. Please do not reply to this message. <br><br> Thank you, <br> Student Government Association Justice Board";
     // Construct the message
     $message = Swift_Message::newInstance('[Marist SGA] Your Parking Appeal Has Been Reviewed')->setFrom(array('sga.judicial@marist.edu' => 'SGA Judicial Board'))->setTo(array($email => 'Appellant'))->addPart('This email is autogenerated to let you know that your appeal has been reviewed by the Justice Board. Please login to the Online Parking Appeal System at http://sga.marist.edu/parkingappeals to review the decision. ', 'text/plain')->setBody($body, 'text/html');
     // Send the email
     $mailer->send($message);
     return Redirect::to('jboard/')->with('alertMessage', 'Ruling submitted successfully.');
 }
开发者ID:nkwsy,项目名称:ParkingAppeal,代码行数:33,代码来源:jboard.php

示例12: run

 /**
  * run() is the start-point of the CLI request, the
  * first argument specifies the command, and sub-sequent
  * arguments are passed as arguments to the chosen generator.
  *
  * @param $arguments array The command and its arguments.
  * @return void
  */
 public function run($arguments = array())
 {
     if (!count($arguments)) {
         $this->_help();
     }
     // setup ansi support
     Common::detect_windows();
     // assign the params
     $command = $arguments[0] !== '' ? $arguments[0] : 'help';
     $args = array_slice($arguments, 1);
     switch ($command) {
         case "controller":
         case "c":
             new Generators_Controller($args);
             break;
         case "model":
         case "m":
             new Generators_Model($args);
             break;
         case "alias":
             new Generators_Alias($args);
             break;
         case "migration":
         case "mig":
             IoC::resolve('task: migrate')->make($args);
             break;
         case "bundle":
         case "b":
             new Generators_Bundle($args);
             break;
         case "test":
         case "t":
             new Generators_Test($args);
             break;
         case "task":
         case "ta":
             new Generators_Task($args);
             break;
         case "class":
         case "cl":
             new Generators_Class($args);
             break;
         case "install":
         case "i":
             IoC::resolve('task: bundle')->install($args);
             break;
         case "config":
         case "co":
             new Generators_Config($args);
             break;
         case "view":
         case "v":
             new Generators_View($args);
             break;
         default:
             $this->_help();
             break;
     }
 }
开发者ID:gigikiri,项目名称:masjid-l3,代码行数:67,代码来源:build.php

示例13: with

 /**
  * Add an item to the session flash data.
  *
  * This is useful for passing status messages or other temporary data to the next request.
  *
  * <code>
  *		// Create a redirect response and flash something to the session
  *		return Redirect::to('user/profile')->with('message', 'Welcome Back!');
  * </code>
  *
  * @param  string          $key
  * @param  mixed           $value
  * @return Response
  */
 public function with($key, $value)
 {
     if (Config::get('session.driver') == '') {
         throw new \LogicException('A session driver must be set before setting flash data.');
     }
     IoC::core('session')->flash($key, $value);
     return $this;
 }
开发者ID:nshontz,项目名称:laravel-blog,代码行数:22,代码来源:redirect.php

示例14: purchaseDiscountedProduct

 public function purchaseDiscountedProduct($product, $discountPercentage)
 {
     $origPrice = $product->getPrice();
     $newPrice = $origPrice - $discountPercentage / 100 * $origPrice;
     $discountedProduct = IoC::make('Product', [$product->getName(), $newPrice]);
     $this->logger->log("Applying discount to " . $product->getName());
     $this->purchase($discountedProduct);
 }
开发者ID:elagith,项目名称:learningMaterial,代码行数:8,代码来源:PurchaseManager.php

示例15: run

 /**
  * Run the test and create a TestLog.
  */
 public function run()
 {
     $tester = IoC::resolve('tester');
     $passed = $tester->test($this->type, $this->url, $this->options);
     $message = $passed ? 'Test Passed' : 'Test Failed';
     #todo: more descriptive messages
     Test\Log::create(array('test_id' => $this->id, 'message' => $message, 'passed' => $passed));
 }
开发者ID:netcon-source,项目名称:clementia,代码行数:11,代码来源:test.php


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