GitHub Project

layout: default language: 'zh-cn' version: '4.0' title: 'Phalcon\Html'

Class Phalcon\Html\Attributes

Source on GitHub

| Namespace | Phalcon\Html | | Uses | Phalcon\Collection, Phalcon\Html\Attributes\RenderInterface, Phalcon\Tag | | Extends | Collection | | Implements | RenderInterface |

This class helps to work with HTML Attributes

Methods

public function __toString(): string;

Alias of the render method

public function render(): string;

Render attributes as HTML attributes

Interface Phalcon\Html\Attributes\AttributesInterface

Source on GitHub

| Namespace | Phalcon\Html\Attributes | | Uses | Phalcon\Html\Attributes |

  • Phalcon\Html\Attributes\AttributesInterface
  • Interface Phalcon\Html\Attributes\AttributesInterface */

Methods

public function getAttributes(): Attributes;

Get Attributes

public function setAttributes( Attributes $attributes ): AttributesInterface;

Set Attributes

Interface Phalcon\Html\Attributes\RenderInterface

Source on GitHub

| Namespace | Phalcon\Html\Attributes |

  • Phalcon\Html\Attributes\RenderInterface
  • Interface Phalcon\Html\Attributes\RenderInterface */

Methods

public function render(): string;

Generate a string represetation

Class Phalcon\Html\Breadcrumbs

Source on GitHub

| Namespace | Phalcon\Html | | Uses | Phalcon\Di\DiInterface |

Phalcon\Html\Breadcrumbs

This component offers an easy way to create breadcrumbs for your application. The resulting HTML when calling render() will have each breadcrumb enclosed in <dt> tags, while the whole string is enclosed in <dl> tags.

Properties

/**
 * Keeps all the breadcrumbs
 *
 * @var array
 */
private elements;

/**
 * Crumb separator
 *
 * @var string
 */
private separator =  / ;

/**
 * The HTML template to use to render the breadcrumbs.
 *
 * @var string
 */
private template = <dt><a href=\"%link%\">%label%</a></dt>;

Methods

public function add( string $label, string $link = string ): Breadcrumbs;

Adds a new crumb.

// Adding a crumb with a link
$breadcrumbs->add("Home", "/");

// Adding a crumb without a link (normally the last one)
$breadcrumbs->add("Users");
public function clear(): void;

Clears the crumbs

$breadcrumbs->clear()
public function getSeparator(): string
public function remove( string $link ): void;

Removes crumb by url.

$breadcrumbs->remove("/admin/user/create");

// remove a crumb without an url (last link)
$breadcrumbs->remove();
public function render(): string;

Renders and outputs breadcrumbs based on previously set template.

echo $breadcrumbs->render();
public function setSeparator( string $separator )
public function toArray(): array;

Returns the internal breadcrumbs array

Class Phalcon\Html\Exception

Source on GitHub

| Namespace | Phalcon\Html | | Extends | \Phalcon\Exception |

Phalcon\Html\Tag\Exception

Exceptions thrown in Phalcon\Html\Tag will use this class

Abstract Class Phalcon\Html\Helper\AbstractHelper

Source on GitHub

| Namespace | Phalcon\Html\Helper | | Uses | Phalcon\Html\Exception, Phalcon\Escaper\EscaperInterface |

Phalcon\Html\Helper\AbstractHelper

Abstract class for all html helpers

Properties

/**
 * @var EscaperInterface
 */
protected escaper;

Methods

public function __construct( EscaperInterface $escaper );

Constructor

protected function orderAttributes( array $overrides, array $attributes ): array;

Keeps all the attributes sorted - same order all the tome

@return array

protected function renderAttributes( array $attributes ): string;

Renders all the attributes

protected function renderElement( string $tag, array $attributes = [] ): string;

Renders an element

protected function renderFullElement( string $tag, string $text, array $attributes = [], bool $raw = bool ): string;

Renders an element

protected function selfClose( string $tag, array $attributes = [] ): string;

Produces a self close tag i.e.

Class Phalcon\Html\Helper\Anchor

Source on GitHub

| Namespace | Phalcon\Html\Helper | | Extends | AbstractHelper |

Phalcon\Html\Helper\Anchor

Creates an anchor

Methods

public function __invoke( string $href, string $text, array $attributes = [] ): string;

@var string href The href tag @var string text The text for the anchor @var array attributes Any additional attributes

Class Phalcon\Html\Helper\AnchorRaw

Source on GitHub

| Namespace | Phalcon\Html\Helper | | Extends | AbstractHelper |

Phalcon\Html\Helper\AnchorRaw

Creates a raw anchor

Methods

public function __invoke( string $href, string $text, array $attributes = [] ): string;

@var string href The href tag @var string text The text for the anchor @var array attributes Any additional attributes

Class Phalcon\Html\Helper\Body

Source on GitHub

| Namespace | Phalcon\Html\Helper | | Extends | AbstractHelper |

Phalcon\Html\Helper\Body

Creates a body tag

Methods

public function __invoke( array $attributes = [] ): string;

@var array attributes Any additional attributes

Class Phalcon\Html\Helper\Button

Source on GitHub

| Namespace | Phalcon\Html\Helper | | Extends | AbstractHelper |

Phalcon\Html\Helper\Button

Creates a button tag

Methods

public function __invoke( string $text, array $attributes = [] ): string;

@var string text The text for the anchor @var array attributes Any additional attributes

Class Phalcon\Html\Helper\Close

Source on GitHub

| Namespace | Phalcon\Html\Helper | | Extends | AbstractHelper |

Phalcon\Html\Helper\Close

Creates a closing tag

Methods

public function __invoke( string $tag ): string;

@return string

Class Phalcon\Html\Helper\Element

Source on GitHub

| Namespace | Phalcon\Html\Helper | | Extends | AbstractHelper |

Phalcon\Html\Helper\Address

Creates an element

Methods

public function __invoke( string $tag, string $text, array $attributes = [] ): string;

@var string tag The tag name @var string text The text for the anchor @var array attributes Any additional attributes

Class Phalcon\Html\Helper\ElementRaw

Source on GitHub

| Namespace | Phalcon\Html\Helper | | Uses | Phalcon\Html\Exception | | Extends | AbstractHelper |

Phalcon\Html\Helper\ElementRaw

Creates an element raw

Methods

public function __invoke( string $tag, string $text, array $attributes = [] ): string;

@return string @throws Exception

Class Phalcon\Html\Helper\Form

Source on GitHub

| Namespace | Phalcon\Html\Helper | | Extends | AbstractHelper |

Phalcon\Html\Helper\Form

Creates a form opening tag

Methods

public function __invoke( array $attributes = [] ): string;

@var array attributes Any additional attributes

Class Phalcon\Html\Helper\Img

Source on GitHub

| Namespace | Phalcon\Html\Helper | | Uses | Phalcon\Html\Exception | | Extends | AbstractHelper |

Phalcon\Html\Helper\Img

Creates am img tag

Methods

public function __invoke( string $src, array $attributes = [] ): string;

@return string @throws Exception

Class Phalcon\Html\Helper\Label

Source on GitHub

| Namespace | Phalcon\Html\Helper | | Uses | Phalcon\Html\Exception | | Extends | AbstractHelper |

Phalcon\Html\Helper\Label

Creates a label

Methods

public function __invoke( array $attributes = [] ): string;

@return string @throws Exception

Class Phalcon\Html\Helper\TextArea

Source on GitHub

| Namespace | Phalcon\Html\Helper | | Extends | AbstractHelper |

Phalcon\Html\Helper\TextArea

Creates a textarea tag

Methods

public function __invoke( string $text, array $attributes = [] ): string;

@var string text The text for the anchor @var array attributes Any additional attributes

Class Phalcon\Html\Link\EvolvableLink

Source on GitHub

| Namespace | Phalcon\Html\Link | | Uses | Psr\Link\EvolvableLinkInterface | | Extends | Link | | Implements | EvolvableLinkInterface |

Class Phalcon\Http\Link\EvolvableLink

@property array attributes @property string href @property array rels @property bool templated

Methods

public function withAttribute( mixed $attribute, mixed $value );

Returns an instance with the specified attribute added.

If the specified attribute is already present, it will be overwritten with the new value.

@return static

public function withHref( mixed $href );

Returns an instance with the specified href.

  The href value to include.  It must be one of:

  - An absolute URI, as defined by RFC 5988.
  - A relative URI, as defined by RFC 5988. The base of the relative
  link is assumed to be known based on context by the client.
  - A URI template as defined by RFC 6570.
  - An object implementing __toString() that produces one of the
  above values.

An implementing library SHOULD evaluate a passed object to a string immediately rather than waiting for it to be returned later.

@return static

public function withRel( mixed $rel );

Returns an instance with the specified relationship included.

If the specified rel is already present, this method MUST return normally without errors, but without adding the rel a second time.

The relationship value to add.

@return static

public function withoutAttribute( mixed $attribute );

Returns an instance with the specified attribute excluded.

If the specified attribute is not present, this method MUST return normally without errors.

The attribute to remove.

@return static

public function withoutRel( mixed $rel );

Returns an instance with the specified relationship excluded.

If the specified rel is already not present, this method MUST return normally without errors.

The relationship value to exclude.

@return static

Class Phalcon\Html\Link\EvolvableLinkProvider

Source on GitHub

| Namespace | Phalcon\Html\Link | | Uses | Psr\Link\EvolvableLinkProviderInterface, Psr\Link\LinkInterface | | Extends | LinkProvider | | Implements | EvolvableLinkProviderInterface |

Class Phalcon\Http\Link\LinkProvider

@property LinkInterface[] links

Methods

public function withLink( LinkInterface $link );

Returns an instance with the specified link included.

If the specified link is already present, this method MUST return normally without errors. The link is present if link is === identical to a link object already in the collection.

A link object that should be included in this collection.

@return static

public function withoutLink( LinkInterface $link );

Returns an instance with the specified link removed.

If the specified link is not present, this method MUST return normally without errors. The link is present if link is === identical to a link object already in the collection.

The link to remove.

@return static

Class Phalcon\Html\Link\Link

Source on GitHub

| Namespace | Phalcon\Html\Link | | Uses | Phalcon\Collection, Psr\Link\LinkInterface | | Implements | LinkInterface |

Class Phalcon\Http\Link\Link

@property array attributes @property string href @property array rels @property bool templated

Properties

/**
 * @var Collection
 */
protected attributes;

/**
 * @var string
 */
protected href = ;

/**
 * @var Collection
 */
protected rels;

/**
 * @var bool
 */
protected templated = false;

Methods

public function __construct( string $rel = string, string $href = string, array $attributes = [] );

Link constructor.

public function getAttributes();

Returns a list of attributes that describe the target URI.

@return array A key-value list of attributes, where the key is a string and the value is either a PHP primitive or an array of PHP strings. If no values are found an empty array MUST be returned.

public function getHref();

Returns the target of the link.

The target link must be one of:

  • An absolute URI, as defined by RFC 5988.
  • A relative URI, as defined by RFC 5988. The base of the relative link is assumed to be known based on context by the client.
  • A URI template as defined by RFC 6570.

If a URI template is returned, isTemplated() MUST return True.

@return string

public function getRels();

Returns the relationship type(s) of the link.

This method returns 0 or more relationship types for a link, expressed as an array of strings.

@return string[]

public function isTemplated();

Returns whether or not this is a templated link.

@return bool True if this link object is templated, False otherwise.

protected function hrefIsTemplated( string $href ): bool;

Determines if a href is a templated link or not.

@see https://tools.ietf.org/html/rfc6570

@return bool

Class Phalcon\Html\Link\LinkProvider

Source on GitHub

| Namespace | Phalcon\Html\Link | | Uses | Psr\Link\LinkInterface, Psr\Link\LinkProviderInterface | | Implements | LinkProviderInterface |

Class Phalcon\Http\Link\LinkProvider

@property LinkInterface[] links

Properties

/**
 * @var LinkInterface[]
 */
protected links;

Methods

public function __construct( array $links = [] );

LinkProvider constructor.

public function getLinks();

Returns an iterable of LinkInterface objects.

The iterable may be an array or any PHP \Traversable object. If no links are available, an empty array or \Traversable MUST be returned.

@return LinkInterface[]|\Traversable

public function getLinksByRel( mixed $rel );

Returns an iterable of LinkInterface objects that have a specific relationship.

The iterable may be an array or any PHP \Traversable object. If no links with that relationship are available, an empty array or \Traversable MUST be returned.

@return LinkInterface[]|Traversable

protected function getKey( LinkInterface $link ): string;

Returns the object hash key

@return string

Class Phalcon\Html\Link\Serializer\Header

Source on GitHub

| Namespace | Phalcon\Html\Link\Serializer | | Uses | Psr\Link\EvolvableLinkInterface | | Implements | SerializerInterface |

Class Phalcon\Http\Link\Serializer\Header

Methods

public function serialize( array $links ): string | null;

Serializes all the passed links to a HTTP link header

Interface Phalcon\Html\Link\Serializer\SerializerInterface

Source on GitHub

| Namespace | Phalcon\Html\Link\Serializer |

Class Phalcon\Http\Link\Serializer\SerializerInterface

Methods

public function serialize( array $links ): string | null;

Serializer method

Class Phalcon\Html\TagFactory

Source on GitHub

| Namespace | Phalcon\Html | | Uses | Phalcon\Escaper, Phalcon\Escaper\EscaperInterface, Phalcon\Factory\AbstractFactory | | Extends | AbstractFactory |

ServiceLocator implementation for Tag helpers

Properties

/**
 * @var EscaperInterface
 */
private escaper;

Methods

public function __construct( EscaperInterface $escaper, array $services = [] );

TagFactory constructor.

public function newInstance( string $name ): mixed;

@return mixed @throws Exception

protected function getAdapters(): array;

//