lithium\console\command\Library::find PHP Method

find() public method

List all the plugins and extensions available on the server.
public find ( string $type = 'plugins' ) : void
$type string plugins|extensions
return void
    public function find($type = 'plugins')
    {
        $results = array();
        foreach ($this->_settings['servers'] as $server => $enabled) {
            if (!$enabled) {
                continue;
            }
            $service = $this->_instance('service', array('host' => $server, 'port' => $this->port));
            $results[$server] = json_decode($service->get("lab/{$type}.json"));
            if (empty($results[$server])) {
                $this->out("No {$type} at {$server}");
                continue;
            }
            foreach ((array) $results[$server] as $data) {
                $name = isset($data->class) ? $data->class : $data->name;
                $header = "{$server} > {$name}";
                $out = array("{$data->summary}", "Version: {$data->version}", "Created: {$data->created}");
                $this->header($header);
                $this->out(array_filter($out));
            }
        }
    }

Usage Example

Example #1
0
 public function testFindNotFound()
 {
     $this->request->params += array('server' => null);
     $library = new Library(array('request' => $this->request, 'classes' => $this->classes));
     $library->conf = $this->testConf;
     $library->config('server', 'localhost');
     $library->find();
     $expected = "No plugins at localhost\n";
     $result = $library->response->output;
     $this->assertEqual($expected, $result);
 }