示例#1
0
 /**
  * Creates and returns a var javascript object
  *
  * @param string $name
  *            Variables name
  * @param mixed $value
  *            Variables values
  * @param boolean $is_string
  *            Flag variable as string to automatically applying quotes
  * @param boolean $defer
  *            Optional flag to put objects output right before the closing body tag. (Default: true)
  * @param boolean $combine
  *            Optional flag to switch combining for this object on or off. (Default: true)
  * @param boolean $minify
  *            Optional flag to switch minifying for this object on or off. (Default: true)
  *            Applies only when $combine argument is set to true.
  *
  * @return JavascriptObject
  */
 public function &createVariable($name, $value, $is_string = false, $defer = false, $combine = true, $minify = true)
 {
     if ($is_string == true) {
         $value = '"' . $value . '"';
     }
     $obj = new JavascriptObject();
     $obj->setType($obj::TYPE_VAR);
     $obj->setContent([$name, $value]);
     $obj->setDefer($defer);
     $obj->setCombine($combine);
     $obj->setMinify($minify);
     $this->addObject($obj);
     return $obj;
 }
 /**
  *
  * {@inheritdoc}
  *
  * @see \Core\Framework\Amvc\App\Javascript\JavascriptHandlerInterface::variable($name, $value, $is_string, $defer)
  */
 public function variable(string $name, $value, bool $is_string = false, bool $defer = true) : JavascriptObjectInterface
 {
     if ($is_string == true) {
         $value = '"' . $value . '"';
     }
     $object = new JavascriptObject();
     $object->setType($object::TYPE_VAR);
     $object->setContent([$name, $value]);
     $object->setDefer($defer);
     $this->add($object);
     return $object;
 }