Xpressengine\Editor\EditorHandler::getTool PHP Méthode

getTool() public méthode

Get a tool
public getTool ( string $toolId, string $instanceId ) : AbstractTool | null
$toolId string tool id
$instanceId string instance id
Résultat AbstractTool | null
    public function getTool($toolId, $instanceId)
    {
        foreach ($this->getToolAll() as $id => $class) {
            if ($toolId === $id) {
                return $this->container->make($class, ['instanceId' => $instanceId]);
            }
        }
        return null;
    }

Usage Example

 /**
  * Get activated tools for the editor
  *
  * @return AbstractTool[]
  */
 public function getTools()
 {
     if ($this->tools === null) {
         $this->tools = [];
         foreach ($this->getActivateToolIds() as $toolId) {
             if ($tool = $this->editors->getTool($toolId, $this->instanceId)) {
                 $this->tools[] = $tool;
             }
         }
     }
     return $this->tools;
 }