Skip to content

Instantly share code, notes, and snippets.

@andidp
Last active November 28, 2022 15:22
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andidp/a54c296c28a95464e33b to your computer and use it in GitHub Desktop.
Save andidp/a54c296c28a95464e33b to your computer and use it in GitHub Desktop.
Call Helper Function for using it on Controller in Cakephp 3
<?php
namespace App\Controller;
use App\Controller\AppController;
// Use Link Helper Class
use App\View\Helper\LinkHelper;
/**
* ProductCategories Controller
*
* @property \App\Model\Table\ProductCategoriesTable $ProductCategories
*/
class ProductCategoriesController extends AppController
{
/**
* Index method
*
* @return void
*/
public function index()
{
// Instantiate LinkHelper
$linkH = new LinkHelper(new \Cake\View\View());
$link = $linkH->makeEdit('test', 'http://google.com');
debug($link);
$this->set('productCategories', $this->paginate($this->ProductCategories));
$this->set('_serialize', ['productCategories']);
}
}
?>
@haroonabbasi
Copy link

For me in cakephp 3 worked with

use Cake\View\Helper\NumberHelper;

@androrim
Copy link

Thanks @andidp

@origamifreak2
Copy link

Worked Great. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment