Skip to content

Commit

Permalink
Removed deprecated methods/features from view/helper
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Sep 15, 2013
1 parent ce0d200 commit 612d569
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 78 deletions.
13 changes: 4 additions & 9 deletions Cake/Test/TestCase/View/Helper/PaginatorHelperTest.php
Expand Up @@ -2268,19 +2268,14 @@ public function testCounter() {
),
)
);
$input = 'Page %page% of %pages%, showing %current% records out of %count% total, ';
$input .= 'starting on record %start%, ending on %end%';
$result = $this->Paginator->counter($input);
$expected = 'Page 1 of 5, showing 3 records out of 13 total, starting on record 1, ';
$expected .= 'ending on 3';
$this->assertEquals($expected, $result);

$input = 'Page {:page} of {:pages}, showing {:current} records out of {:count} total, ';
$input .= 'starting on record {:start}, ending on {:end}';
$expected = 'Page 1 of 5, showing 3 records out of 13 total, starting on record 1, ';
$expected .= 'ending on 3';
$result = $this->Paginator->counter($input);
$this->assertEquals($expected, $result);

$input = 'Page %page% of %pages%';
$input = 'Page {:page} of {:pages}';
$result = $this->Paginator->counter($input);
$expected = 'Page 1 of 5';
$this->assertEquals($expected, $result);
Expand All @@ -2297,7 +2292,7 @@ public function testCounter() {
$expected = '1 - 3 of 13';
$this->assertEquals($expected, $result);

$result = $this->Paginator->counter('Showing %page% of %pages% %model%');
$result = $this->Paginator->counter('Showing {:page} of {:pages} {:model}');
$this->assertEquals('Showing 1 of 5 clients', $result);
}

Expand Down
5 changes: 1 addition & 4 deletions Cake/Test/TestCase/View/Helper/SessionHelperTest.php
Expand Up @@ -179,10 +179,7 @@ public function testFlashElementInAttrs() {
public function testFlashWithPluginElement() {
Plugin::load('TestPlugin');

$result = $this->Session->flash('flash', array(
'element' => 'plugin_element',
'params' => array('plugin' => 'TestPlugin')
));
$result = $this->Session->flash('flash', array('element' => 'TestPlugin.plugin_element'));
$expected = 'this is the plugin element using params[plugin]';
$this->assertEquals($expected, $result);
}
Expand Down
16 changes: 0 additions & 16 deletions Cake/Test/TestCase/View/ViewTest.php
Expand Up @@ -664,12 +664,6 @@ public function testElement() {
$result = $this->View->element('test_element');
$this->assertEquals('this is the test element', $result);

$result = $this->View->element('plugin_element', array(), array('plugin' => 'TestPlugin'));
$this->assertEquals('this is the plugin element using params[plugin]', $result);

$result = $this->View->element('plugin_element', array(), array('plugin' => 'test_plugin'));
$this->assertEquals('this is the plugin element using params[plugin]', $result);

$result = $this->View->element('TestPlugin.plugin_element');
$this->assertEquals('this is the plugin element using params[plugin]', $result);

Expand All @@ -688,16 +682,6 @@ public function testElementInexistent() {
$this->View->element('non_existent_element');
}

/**
* Test elementInexistent2 method
*
* @expectedException PHPUnit_Framework_Error_Notice
* @return void
*/
public function testElementInexistent2() {
$this->View->element('TestPlugin.plugin_element', array(), array('plugin' => 'test_plugin'));
}

/**
* Test elementInexistent3 method
*
Expand Down
21 changes: 7 additions & 14 deletions Cake/View/Helper/PaginatorHelper.php
Expand Up @@ -533,10 +533,8 @@ public function defaultModel() {
* custom content you would like.
* - `separator` The separator string to use, default to ' of '
*
* The `%page%` style placeholders also work, but are deprecated and will be removed in a future version.
* @param array $options Options for the counter string. See #options for list of keys.
* @return string Counter string.
* @deprecated The %page% style placeholders are deprecated.
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/paginator.html#PaginatorHelper::counter
*/
public function counter($options = array()) {
Expand Down Expand Up @@ -578,20 +576,15 @@ public function counter($options = array()) {
break;
default:
$map = array(
'%page%' => $paging['page'],
'%pages%' => $paging['pageCount'],
'%current%' => $paging['current'],
'%count%' => $paging['count'],
'%start%' => $start,
'%end%' => $end,
'%model%' => strtolower(Inflector::humanize(Inflector::tableize($options['model'])))
'{:page}' => $paging['page'],
'{:pages}' => $paging['pageCount'],
'{:current}' => $paging['current'],
'{:count}' => $paging['count'],
'{:start}' => $start,
'{:end}' => $end,
'{:model}' => strtolower(Inflector::humanize(Inflector::tableize($options['model'])))
);
$out = str_replace(array_keys($map), array_values($map), $options['format']);

$newKeys = array(
'{:page}', '{:pages}', '{:current}', '{:count}', '{:start}', '{:end}', '{:model}'
);
$out = str_replace($newKeys, array_values($map), $out);
}
return $out;
}
Expand Down
18 changes: 0 additions & 18 deletions Cake/View/View.php
Expand Up @@ -382,21 +382,14 @@ public function setEventManager(EventManager $eventManager) {
* If an array, the following keys can be used:
* - `config` - Used to store the cached element in a custom cache configuration.
* - `key` - Used to define the key used in the Cache::write(). It will be prefixed with `element_`
* - `plugin` - Load an element from a specific plugin. This option is deprecated, see below.
* - `callbacks` - Set to true to fire beforeRender and afterRender helper callbacks for this element.
* Defaults to false.
* - `ignoreMissing` - Used to allow missing elements. Set to true to not trigger notices.
* @return string Rendered Element
* @deprecated The `$options['plugin']` is deprecated and will be removed in CakePHP 3.0. Use
* `Plugin.element_name` instead.
*/
public function element($name, $data = array(), $options = array()) {
$file = $plugin = null;

if (isset($options['plugin'])) {
$name = Inflector::camelize($options['plugin']) . '.' . $name;
}

if (!isset($options['callbacks'])) {
$options['callbacks'] = false;
}
Expand Down Expand Up @@ -573,17 +566,6 @@ public function getVars() {
return array_keys($this->viewVars);
}

/**
* Returns the contents of the given View variable(s)
*
* @param string $var The view var you want the contents of.
* @return mixed The content of the named var if its set, otherwise null.
* @deprecated Will be removed in 3.0. Use View::get() instead.
*/
public function getVar($var) {
return $this->get($var);
}

/**
* Returns the contents of the given View variable or a block.
* Blocks are checked before view variables.
Expand Down
17 changes: 0 additions & 17 deletions Cake/View/ViewBlock.php
Expand Up @@ -154,23 +154,6 @@ public function concat($name, $value = null, $mode = ViewBlock::APPEND) {
}
}

/**
* Append to an existing or new block. Appending to a new
* block will create the block.
*
* Calling append() without a value will create a new capturing
* block that needs to be finished with View::end(). The content
* of the new capturing context will be added to the existing block context.
*
* @param string $name Name of the block
* @param string $value The content for the block.
* @return void
* @deprecated As of 2.3 use ViewBlock::concat() instead.
*/
public function append($name, $value = null) {
$this->concat($name, $value);
}

/**
* Set the content for a block. This will overwrite any
* existing content.
Expand Down

0 comments on commit 612d569

Please sign in to comment.