Skip to content

Latest commit

 

History

History
executable file
·
67 lines (53 loc) · 1.2 KB

README.md

File metadata and controls

executable file
·
67 lines (53 loc) · 1.2 KB

Altair plugin is for CakePHP3

Auto converting special characters of variables to HTML entities

Requirements

  • PHP >=5.4.16
  • CakePHP >= ~3.0

Usage

<?php
    class AppController extends Controller
    {

        public function initialize()
        {
            $this->loadComponent('Altair.Altair');
        }
        ...
    }

By doing above, You do not have to write the following(h()) every time.

<?= h($variable); ?>

If you do not want to escape $object, use $object->escape property.

<?php
    class UsersController extends AppController
    {

        public function add()
        {
            $user = $this->Users->newEntity();
            ...
            $user->escape = false;
            $this->set('user', $user);
        }
        ...
    }

If you do not want to escape in the action, use $this->Altair->escape() method.

<?php
    class UsersController extends AppController
    {

        public function add()
        {
            $user = $this->Users->newEntity();
            ...
            // Not escape $viewVars in this action.
            $this->Altair->escape(false);
            $this->set('user', $user);
        }
        ...
    }