|
Revision 1397, 1.6 kB
(checked in by bermi, 6 months ago)
|
COnverting converters to PHP5
|
| Line | |
|---|
| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
class AkActiveRecordToYaml |
|---|
| 20 |
{ |
|---|
| 21 |
public function convert() |
|---|
| 22 |
{ |
|---|
| 23 |
$attributes = array(); |
|---|
| 24 |
if(is_array($this->source)){ |
|---|
| 25 |
foreach (array_keys($this->source) as $k){ |
|---|
| 26 |
if($this->_isActiveRecord($this->source[$k])){ |
|---|
| 27 |
$attributes[$this->source[$k]->getId()] = $this->source[$k]->getAttributes(); |
|---|
| 28 |
} |
|---|
| 29 |
} |
|---|
| 30 |
}elseif ($this->_isActiveRecord($this->source)){ |
|---|
| 31 |
$attributes[$this->source->getId()] = $this->source->getAttributes(); |
|---|
| 32 |
} |
|---|
| 33 |
require_once(AK_VENDOR_DIR.DS.'TextParsers'.DS.'spyc.php'); |
|---|
| 34 |
return Spyc::YAMLDump($attributes); |
|---|
| 35 |
} |
|---|
| 36 |
|
|---|
| 37 |
public function _isActiveRecord(&$Candidate) |
|---|
| 38 |
{ |
|---|
| 39 |
return is_object($Candidate) && method_exists($Candidate, 'getAttributes') && method_exists($Candidate, 'getId'); |
|---|
| 40 |
} |
|---|
| 41 |
} |
|---|
| 42 |
|
|---|
| 43 |
?> |
|---|
| 44 |
|
|---|