[ Index ]

PHP Cross Reference of Akelos Framework

title

Body

[close]

/AkConverters/ -> AkActiveRecordToYaml.php (source)

   1  <?php
   2  /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
   3  
   4  // +----------------------------------------------------------------------+
   5  // | Akelos Framework - http://www.akelos.org                             |
   6  // +----------------------------------------------------------------------+
   7  // | Copyright (c) 2002-2006, Akelos Media, S.L.  & Bermi Ferrer Martinez |
   8  // | Released under the GNU Lesser General Public License, see LICENSE.txt|
   9  // +----------------------------------------------------------------------+
  10  
  11  /**
  12   * @package ActiveSupport
  13   * @subpackage Converters
  14   * @author Bermi Ferrer <bermi a.t akelos c.om>
  15   * @copyright Copyright (c) 2002-2006, Akelos Media, S.L. http://www.akelos.org
  16   * @license GNU Lesser General Public License <http://www.gnu.org/copyleft/lesser.html>
  17   */
  18  
  19  class AkActiveRecordToYaml
  20  {
  21      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      function _isActiveRecord(&$Candidate)
  38      {
  39          return is_object($Candidate) && method_exists($Candidate, 'getAttributes') && method_exists($Candidate, 'getId');
  40      }
  41  }
  42  
  43  ?>


Generated: Mon Oct 27 12:43:49 2008 Cross-referenced by PHPXref 0.6