コード例 #1
0
ファイル: InputString.php プロジェクト: gpupo/similarity
 protected function getCleanStringValue($key)
 {
     $d = new Decorator();
     $value = $this->get($key);
     $string = $d->stripIgnoredCharacters($value);
     if ($this->getStopwords()) {
         return $d->stripStopwords($string, $this->getStopwords());
     }
     return $string;
 }
コード例 #2
0
ファイル: Group.php プロジェクト: sachsy/formbuilder
 /**
  * Add a decorator to the element.
  * 
  * @param Decorator|string $decorator  Decorator object or name
  * @param mixed            $_          Additional arguments are passed to the constructor
  * @return Element  $this
  */
 public function addDecorator($decorator)
 {
     // parent::addDecorator($decorator, ...$_);
     call_user_func_array([get_parent_class(), 'addDecorator'], func_get_args());
     foreach ($this->getChildren() as $child) {
         if ($this->getOption('decorate') === false) {
             continue;
         }
         $decorator->apply($child, true);
     }
     return $this;
 }
コード例 #3
0
 /**
  * {@inheritdoc}
  *
  * @throws \InvalidArgumentException
  */
 public function inject($originalValue)
 {
     if (!$this->supports($originalValue)) {
         throw new \InvalidArgumentException('You must provide a resource as the original value to use a ResourceDecorator');
     }
     parent::inject($originalValue);
 }
コード例 #4
0
 /**
  * {@inheritdoc}
  *
  * @throws \InvalidArgumentException
  */
 public function inject($originalValue)
 {
     if (!$this->supports($originalValue)) {
         throw new \InvalidArgumentException('You must provide an object as the original value to use an ObjectDecorator');
     }
     return parent::inject($originalValue);
 }
コード例 #5
0
ファイル: decorator.php プロジェクト: luisOO/design-patterns
 public function operate()
 {
     parent::operate();
     //调用装饰类的操作
     $this->extraOperate();
     //新增加的操作
 }
コード例 #6
0
ファイル: AncodeCache.php プロジェクト: REZ1DENT3/morphy
 function readAncodes($info)
 {
     $offset = $info['offset'];
     if (isset($this->cache[$offset])) {
         $this->hits++;
         return $this->cache[$offset];
     } else {
         // in theory misses never occur
         $this->miss++;
         return parent::readAncodes($info);
     }
 }
コード例 #7
0
ファイル: switcher.php プロジェクト: balucio/smac
 public function render()
 {
     $stato = isset($this->model->result['stato']) ? $this->model->result['stato'] : null;
     $data_ora = isset($this->model->result['data_ora']) ? $this->model->result['data_ora'] : 'now';
     $dec = new Decorator();
     $updated = $dec->decorateDateTime($data_ora);
     if ($stato === true) {
         $classes = 'fa fa-fire status on';
         $title = 'title-status-on';
     } else {
         if ($stato === false) {
             $classes = 'fa fa-fire status off';
             $title = 'title-status-off';
         } else {
             $classes = 'fa fa-exclamation-circle status undefined';
             $title = 'title-status-unknow';
         }
     }
     $result = (object) ['result' => $stato, 'classes' => $classes, 'title' => $title, 'updated' => $updated];
     return json_encode($result, JSON_NUMERIC_CHECK);
 }
コード例 #8
0
ファイル: MyDecorator.php プロジェクト: manachyn/trainings
 public function Operation()
 {
     return '<B>' . parent::Operation() . '</B>';
 }
コード例 #9
0
 public function operation()
 {
     return parent::operation() . ' - ' . $this->addedState;
 }
コード例 #10
0
 public function operation()
 {
     return parent::operation() . ' - ' . $this->addedBehavior();
 }
コード例 #11
0
 public function Operation()
 {
     return '<a href="#">' . parent::Operation() . '</a>';
 }
コード例 #12
0
ファイル: InputNumber.php プロジェクト: gpupo/similarity
 protected function getCleanStringValue($key)
 {
     $d = new Decorator();
     $value = $this->get($key);
     return $d->onlyNumbers($value);
 }
コード例 #13
0
ファイル: Engine.class.php プロジェクト: anp135/altocms
 /**
  * Выполняет загрузку модуля по его названию
  *
  * @param  string $sModuleClass    Класс модуля
  * @param  bool $bInit Инициализировать модуль или нет
  *
  * @throws RuntimeException если класс $sModuleClass не существует
  *
  * @return Module
  */
 public function LoadModule($sModuleClass, $bInit = false)
 {
     $tm1 = microtime(true);
     if (!class_exists($sModuleClass)) {
         throw new RuntimeException(sprintf('Class "%s" not found!', $sModuleClass));
     }
     // * Создаем объект модуля
     $oModule = new $sModuleClass();
     $oModuleDecorator = Decorator::Create($oModule);
     $this->aModules[$sModuleClass] = $oModuleDecorator;
     if ($bInit || $sModuleClass == 'ModuleCache') {
         $this->InitModule($oModuleDecorator);
     }
     $tm2 = microtime(true);
     $this->nTimeLoadModule += $tm2 - $tm1;
     return $oModuleDecorator;
 }
コード例 #14
0
 public function testDecorator()
 {
     $component = new ConcreteComponent();
     $decorator = new Decorator($component);
     $decorator->operate();
 }
コード例 #15
0
ファイル: sensordata.php プロジェクト: balucio/smac
 public function render()
 {
     $dcr = new Decorator();
     return json_encode(['temperature-value' => $dcr->decorateTemperature($this->model->temperatura), 'humidity-value' => $dcr->decorateUmidity($this->model->umidita), 'last-update' => $dcr->decorateDateTime($this->model->ultimo_aggiornamento)], JSON_FORCE_OBJECT | JSON_HEX_QUOT | JSON_HEX_TAG);
 }
コード例 #16
0
 /**
  * @see Base
  */
 public function __construct($string, $options = array(), $messages = array())
 {
     $this->string = $string;
     $this->tokens = $this->tokenize($string);
     parent::__construct($options, $messages);
 }
コード例 #17
0
ファイル: sensorstats.php プロジェクト: balucio/smac
 public function render()
 {
     $dec = new Decorator();
     $updated = $dec->decorateDateTime('now');
     return json_encode((object) ['points' => $this->model->getData(), 'updated' => $updated], JSON_NUMERIC_CHECK);
 }
コード例 #18
0
ファイル: ImageDecorator.php プロジェクト: point/cassea
 function __construct($f)
 {
     parent::__construct($f);
     $this->getImageSize();
 }
コード例 #19
0
ファイル: ThumbDecorator.php プロジェクト: point/cassea
 function __construct($file, array $styles = array("thumb" => "100x100"))
 {
     parent::__construct($file);
     $this->styles = preg_grep("/\\d+x\\d+/", $styles);
 }
コード例 #20
0
 function __construct($component)
 {
     parent::__construct($component);
 }
コード例 #21
0
ファイル: 0.php プロジェクト: ruyicoder/php
 public function operation()
 {
     parent::operation();
     $this->Addbehavior();
     var_dump('具体装饰对象B的操作');
 }
コード例 #22
0
 public function operation()
 {
     parent::operation();
     $this->addedOperationB();
 }
コード例 #23
0
ファイル: index.php プロジェクト: raynaldmo/php-education
<?php

/**
 * Copyright (c) 2014 Keith Casey
 *
 * This code is designed to accompany the lynda.com video course "Design Patterns in PHP"
 *   by Keith Casey. If you've received this code without seeing the videos, go watch the
 *   videos. It will make way more sense and be more useful in general.
 */
include_once 'decorator.php';
$object = new Decorator();
$object->sentence = "This is a sample sentence that we're going to manipulate in the Decorator.";
// This should output: this is a sample sentence that we're going to manipulate in the decorator.
echo $object->lower();
// This should output: THIS IS A SAMPLE SENTENCE THAT WE'RE GOING TO MANIPULATE IN THE DECORATOR.
echo $object->uppercase();
コード例 #24
0
ファイル: LazyWrite.php プロジェクト: anime-db/catalog-bundle
 /**
  * Write all messages from stack.
  */
 public function writeAll()
 {
     while ($message = array_shift($this->stack)) {
         parent::writeln($message[0], $message[1]);
     }
 }
コード例 #25
0
 public function testSpecialPlaceholder()
 {
     $context = new Context('name', 'id');
     $decorator = new Decorator();
     $decorator->context($context);
 }
コード例 #26
0
ファイル: B.php プロジェクト: ITwinkle/test
 public function Operation()
 {
     return 'B :' . parent::Operation();
 }
コード例 #27
0
 public function Operation()
 {
     return '<strong>' . parent::Operation() . '</strong>';
 }
コード例 #28
0
 /**
  * @param RenderInterface $wrapable
  * @param $width
  * @param $color
  */
 public function __construct($wrapable, $width, $color)
 {
     parent::__construct($wrapable);
     $this->width = $width;
     $this->color = $color;
 }
コード例 #29
0
ファイル: Row.php プロジェクト: rafalwrzeszcz/zf2
 /**
  * Render the row
  *
  * @param  array                               $columnWidths Width of all columns
  * @param  \Zend\Text\Table\Decorator $decorator    Decorator for the row borders
  * @param  integer                             $padding      Padding for the columns
  * @throws \Zend\Text\Table\Exception\OverflowException When there are too many columns
  * @return string
  */
 public function render(array $columnWidths, Decorator $decorator, $padding = 0)
 {
     // Prepare an array to store all column widths
     $this->_columnWidths = array();
     // If there is no single column, create a column which spans over the
     // entire row
     if (count($this->_columns) === 0) {
         $this->appendColumn(new Column(null, null, count($columnWidths)));
     }
     // First we have to render all columns, to get the maximum height
     $renderedColumns = array();
     $maxHeight = 0;
     $colNum = 0;
     foreach ($this->_columns as $column) {
         // Get the colspan of the column
         $colSpan = $column->getColSpan();
         // Verify if there are enough column widths defined
         if ($colNum + $colSpan > count($columnWidths)) {
             throw new Exception\OverflowException('Too many columns');
         }
         // Calculate the column width
         $columnWidth = $colSpan - 1 + array_sum(array_slice($columnWidths, $colNum, $colSpan));
         // Render the column and split it's lines into an array
         $result = explode("\n", $column->render($columnWidth, $padding));
         // Store the width of the rendered column
         $this->_columnWidths[] = $columnWidth;
         // Store the rendered column and calculate the new max height
         $renderedColumns[] = $result;
         $maxHeight = max($maxHeight, count($result));
         // Set up the internal column number
         $colNum += $colSpan;
     }
     // If the row doesnt contain enough columns to fill the entire row, fill
     // it with an empty column
     if ($colNum < count($columnWidths)) {
         $remainingWidth = count($columnWidths) - $colNum - 1 + array_sum(array_slice($columnWidths, $colNum));
         $renderedColumns[] = array(str_repeat(' ', $remainingWidth));
         $this->_columnWidths[] = $remainingWidth;
     }
     // Add each single column line to the result
     $result = '';
     for ($line = 0; $line < $maxHeight; $line++) {
         $result .= $decorator->getVertical();
         foreach ($renderedColumns as $renderedColumn) {
             if (isset($renderedColumn[$line]) === true) {
                 $result .= $renderedColumn[$line];
             } else {
                 $result .= str_repeat(' ', strlen($renderedColumn[0]));
             }
             $result .= $decorator->getVertical();
         }
         $result .= "\n";
     }
     return $result;
 }
コード例 #30
0
ファイル: programdata.php プロジェクト: balucio/smac
 public function render()
 {
     $dcr = new Decorator();
     return json_encode((object) ['dettaglio' => $this->model->dettaglio, 'temp_antigelo' => $this->model->antigelo, 'temperature' => $this->model->temperature, 'temp_riferimento' => $this->encodeHtml($this->model), 'temp_rif_att' => $dcr->decorateTemperature($this->model->rif_temp_attuale)]);
 }