public static function retrieveByConfig($config) { $c = []; $entries = AstConfigQuery::create()->filterByFilename($config)->filterByCategory('general', Criteria::NOT_EQUAL)->orderByCatMetric()->orderByVarMetric()->find(); if ($entries->count() > 0) { $class = get_called_class(); /** @var AstConfig $row */ foreach ($entries as $row) { $category = $row->getCategory(); if (array_key_exists($category, $c)) { $astConfigObj = $c[$category]; } else { /** @var $astConfigObj Dfi_Asterisk_Static_ConfigAbstract */ $astConfigObj = new self($config, $category); $c[$category] = $astConfigObj; } $entry = new Dfi_Asterisk_Static_Entry($row); $astConfigObj->addEntry($entry); } } return $c; }
public static function getConfigMappings() { $found = []; $res = Dfi_Asterisk_Ami::send(new \PAMI\Message\Action\CommandAction('core show config mappings')); if (!$res instanceof \PAMI\Message\Response\ResponseMessage) { $cat = AstConfigQuery::create()->select('FileName')->distinct()->find(); return $cat->toArray(); } $lines = explode("\n", array_pop(explode("\r\n", $res->getRawContent()))); $i = 0; $started = false; while (true) { $line = $lines[$i]; if ($started && preg_match('/Config Engine/', $line)) { break; } if ($started) { $found[] = preg_replace('/\\s*===> ([a-z]+\\.conf).*/', '$1', $line); } if ($line == 'Config Engine: odbc') { $started = true; } $i++; if ($i == count($lines)) { break; } } return $found; }
/** * @param $category string * @return Dfi_Asterisk_Static_ConfigAbstract */ public static function retrieveByCategory($category) { $entries = AstConfigQuery::create()->filterByFilename(self::getFileName())->filterByCategory($category)->orderByVarMetric()->find(); if ($entries->count() > 0) { $class = get_called_class(); /** @var $obj Dfi_Asterisk_Static_ConfigAbstract */ $obj = new $class($category); foreach ($entries as $row) { $entry = new Dfi_Asterisk_Static_Entry($row); $obj->addEntry($entry); } } else { $obj = false; } return $obj; }