Autodoc
  • Namespace
  • Class
  • Tree

Namespaces

  • BlueTihi
    • Context
  • Brickrouge
    • Element
      • Nodes
    • Renderer
    • Widget
  • ICanBoogie
    • ActiveRecord
    • AutoConfig
    • CLDR
    • Composer
    • Core
    • Event
    • Exception
    • HTTP
      • Dispatcher
      • Request
    • I18n
      • Translator
    • Mailer
    • Modules
      • Taxonomy
        • Support
      • Thumbnailer
        • Versions
    • Object
    • Operation
      • Dispatcher
    • Prototype
    • Routes
    • Routing
      • Dispatcher
    • Session
  • Icybee
    • ActiveRecord
      • Model
    • ConfigOperation
    • Document
    • EditBlock
    • Element
      • ActionbarContextual
      • ActionbarSearch
      • ActionbarToolbar
    • FormBlock
    • Installer
    • ManageBlock
    • Modules
      • Articles
      • Cache
        • Collection
        • ManageBlock
      • Comments
        • ManageBlock
      • Contents
        • ManageBlock
      • Dashboard
      • Editor
        • Collection
      • Files
        • File
        • ManageBlock
      • Forms
        • Form
        • ManageBlock
      • I18n
      • Images
        • ManageBlock
      • Members
      • Modules
        • ManageBlock
      • Nodes
        • ManageBlock
        • Module
      • Pages
        • BreadcrumbElement
        • LanguagesElement
        • ManageBlock
        • NavigationBranchElement
        • NavigationElement
        • Page
        • PageController
      • Registry
      • Search
      • Seo
      • Sites
        • ManageBlock
      • Taxonomy
        • Terms
          • ManageBlock
        • Vocabulary
          • ManageBlock
      • Users
        • ManageBlock
        • NonceLogin
        • Roles
      • Views
        • ActiveRecordProvider
        • Collection
        • View
    • Operation
      • ActiveRecord
      • Constructor
      • Module
      • Widget
    • Rendering
  • None
  • Patron
  • PHP

Classes

  • CoreConfigRequirement
  • DatabaseForm
  • DatabaseOperation
  • DocumentDecorator
  • InstallForm
  • InstallOperation
  • InstallRequirements
  • LanguageElement
  • Operation
  • PanelDecorator
  • PanelForm
  • PDODriversRequirement
  • RepositoryRequirement
  • Requirement
  • Requirements
  • RequirementsOperation
  • SiteForm
  • SiteOperation
  • StepsController
  • TellMeMore
  • UserConfigRequirement
  • UserForm
  • UserOperation
  • WelcomePanel
  • WelcomeRequirements

Functions

  • t
  1 <?php
  2 
  3 /*
  4  * This file is part of the Icybee/Installer package.
  5  *
  6  * (c) Olivier Laviale <olivier.laviale@gmail.com>
  7  *
  8  * For the full copyright and license information, please view the LICENSE
  9  * file that was distributed with this source code.
 10  */
 11 
 12 namespace Icybee\Installer;
 13 
 14 use ICanBoogie\Errors;
 15 use ICanBoogie\I18n;
 16 use ICanBoogie\I18n\FormattedString;
 17 
 18 use Brickrouge\Alert;
 19 use Brickrouge\Button;
 20 
 21 class Requirements implements \IteratorAggregate
 22 {
 23     static public function get()
 24     {
 25         return new static;
 26     }
 27 
 28     protected $title;
 29     protected $requirements;
 30 
 31     public function __construct($title, array $requirements)
 32     {
 33         $this->title = $title;
 34         $this->requirements = $requirements;
 35     }
 36 
 37     public function __invoke(Errors $errors)
 38     {
 39         foreach ($this->requirements as $requirement)
 40         {
 41             $requirement($errors);
 42         }
 43 
 44         return !$errors->count();
 45     }
 46 
 47     public function getIterator()
 48     {
 49         return new \ArrayIterator($this->requirements);
 50     }
 51 
 52     public function render()
 53     {
 54         $html = '';
 55         $errors = new Errors();
 56 
 57         foreach ($this->requirements as $id => $requirement)
 58         {
 59             $errors->clear();
 60             $requirement($errors);
 61 
 62             if (!$errors->count())
 63             {
 64                 continue;
 65             }
 66 
 67             $html .= $requirement->render($errors);
 68         }
 69 
 70         if (!$html)
 71         {
 72             return;
 73         }
 74 
 75         $action = new Button("Check again", array('class' => 'btn-primary'));
 76 
 77         return <<<EOT
 78 <div class="requirements">
 79     <h2>{$this->title}</h2>
 80     $html
 81     <p>{$action}</p>
 82 </div>
 83 EOT;
 84     }
 85 }
 86 
 87 class WelcomeRequirements extends Requirements
 88 {
 89     public function __construct()
 90     {
 91         parent::__construct
 92         (
 93             I18n\t("Before we can continue, you need to check the following things:"), array
 94             (
 95                 'repository' => new RepositoryRequirement,
 96                 'user_config' => new UserConfigRequirement,
 97                 'pdo_drivers' => new PDODriversRequirement
 98             )
 99         );
100     }
101 }
102 
103 class InstallRequirements extends Requirements
104 {
105     static public function get()
106     {
107         return new static
108         (
109             I18n\t("Before we can continue, you need to check the following things:"), array
110             (
111                 'core_config' => new CoreConfigRequirement
112             )
113         );
114     }
115 }
116 
117 /**
118  * Representation of a requirement.
119  */
120 abstract class Requirement
121 {
122     public $title;
123     public $description;
124 
125     abstract public function __invoke(Errors $errors);
126 
127     /**
128      * Renders the requirement along with the specified errors.
129      *
130      * @param Errors $errors
131      *
132      * @return string
133      */
134     public function render(Errors $errors)
135     {
136         $alert = new Alert($errors, array(Alert::UNDISSMISABLE => true));
137 
138         return <<<EOT
139 <div class="requirement">
140     <h3 class="requirement-title">{$this->title}</h3>
141     <div class="requirement-description">{$this->description}</div>
142     {$alert}
143 </div>
144 EOT;
145     }
146 }
Autodoc API documentation generated by ApiGen 2.8.0