Development

Changeset 8133

You must first sign up to be able to contribute.

Changeset 8133

Show
Ignore:
Timestamp:
03/28/08 10:30:13 (5 months ago)
Author:
dwhittle
Message:

dwhittle: merged changes to branch

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/propel/addon/sfPropelData.class.php

    r7918 r8133  
    9696      { 
    9797        // create a new entry in the database 
     98        if (!class_exists($class)) 
     99        { 
     100          throw new InvalidArgumentException(sprintf('Unknown class "%s".', $class)); 
     101        } 
     102 
    98103        $obj = new $class(); 
    99104 
    100105        if (!$obj instanceof BaseObject) 
    101106        { 
    102           throw new Exception(sprintf('The class "%s" is not a Propel class. This probably means there is already a class named "%s" somewhere in symfony or in your project.', $class, $class)); 
     107          throw new RuntimeException(sprintf('The class "%s" is not a Propel class. This probably means there is already a class named "%s" somewhere in symfony or in your project.', $class, $class)); 
    103108        } 
    104109 
    105110        if (!is_array($data)) 
    106111        { 
    107           throw new Exception(sprintf('You must give a name for each fixture data entry (class %s)', $class)); 
     112          throw new InvalidArgumentException(sprintf('You must give a name for each fixture data entry (class %s).', $class)); 
    108113        } 
    109114 
     
    137142              if (!isset($this->object_references[$relatedTable->getPhpName().'_'.$value])) 
    138143              { 
    139                 throw new sfException(sprintf('The object "%s" from class "%s" is not defined in your data file.', $value, $relatedTable->getPhpName())); 
     144                throw new InvalidArgumentException(sprintf('The object "%s" from class "%s" is not defined in your data file.', $value, $relatedTable->getPhpName())); 
    140145              } 
    141146              $value = $this->object_references[$relatedTable->getPhpName().'_'.$value]->getPrimaryKey(); 
     
    153158          else 
    154159          { 
    155             throw new sfException(sprintf('Column "%s" does not exist for class "%s"', $name, $class)); 
     160            throw new InvalidArgumentException(sprintf('Column "%s" does not exist for class "%s".', $name, $class)); 
    156161          } 
    157162        } 
     
    189194    if (!isset($relatedClass)) 
    190195    { 
    191       throw new sfException(sprintf('Unable to find the many-to-many relationship for object "%s"', get_class($obj))); 
     196      throw new InvalidArgumentException(sprintf('Unable to find the many-to-many relationship for object "%s".', get_class($obj))); 
    192197    } 
    193198 
     
    199204      if (!isset($this->object_references[$relatedClass.'_'.$value])) 
    200205      { 
    201         throw new sfException(sprintf('The object "%s" from class "%s" is not defined in your data file.', $value, $relatedClass)); 
     206        throw new InvalidArgumentException(sprintf('The object "%s" from class "%s" is not defined in your data file.', $value, $relatedClass)); 
    202207      } 
    203208 
     
    245250        { 
    246251          continue; 
     252        } 
     253 
     254        // Check that peer class exists before calling doDeleteAll() 
     255        if (!class_exists($class.'Peer')) 
     256        { 
     257          throw new InvalidArgumentException(sprintf('Unknown class "%sPeer".', $class)); 
    247258        } 
    248259 
  • branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/classes/propel/engine/builder/om/php5/PHP5ObjectBuilder.php

    r7989 r8133  
    22 
    33/* 
    4  *  $Id: PHP5ObjectBuilder.php 1006 2008-03-19 15:30:19Z hans $ 
     4 *  $Id: PHP5ObjectBuilder.php 1017 2008-03-27 17:58:03Z hans $ 
    55 * 
    66 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
     
    32753275        $vars[] = $varName; 
    32763276        $script .= " 
    3277       \$this->{$varName}->clearAllReferences(\$deep);"; 
     3277      if (\$this->$varName) { 
     3278        \$this->{$varName}->clearAllReferences(\$deep); 
     3279      }"; 
    32783280      } else { 
    32793281        $varName = $this->getRefFKCollVarName($refFK); 
    32803282        $vars[] = $varName; 
    32813283        $script .= " 
    3282       foreach (\$this->$varName as \$o) { 
    3283         \$o->clearAllReferences(\$deep); 
     3284      if (\$this->$varName) { 
     3285        foreach((array) \$this->$varName as \$o) { 
     3286          \$o->clearAllReferences(\$deep); 
     3287        } 
    32843288      }"; 
    32853289      } 
  • branches/dwhittle/1.1/lib/util/sfYamlParser.class.php

    r7927 r8133  
    2626    $lines         = array(), 
    2727    $currentLineNb = -1, 
    28     $currentLine   = ''; 
     28    $currentLine   = '', 
     29    $refs          = array(); 
    2930 
    3031  /** 
     
    6667      } 
    6768 
     69      $isRef = $isInPlace = false; 
    6870      if (preg_match('#^\-(\s+(?P<value>.+?))?\s*$#', $this->currentLine, $values)) 
    6971      { 
     72        if (isset($values['value']) && preg_match('#^&(?P<ref>\w+) *(?P<value>.*)#', $values['value'], $matches)) 
     73        { 
     74          $isRef = $matches['ref']; 
     75          $values['value'] = $matches['value']; 
     76        } 
     77 
    7078        // array 
    7179        if (!isset($values['value']) || '' == trim($values['value'], ' ') || 0 === strpos(ltrim($values['value'], ' '), '#')) 
     
    7381          $c = $this->getRealCurrentLineNb() + 1; 
    7482          $parser = new sfYamlParser($c); 
     83          $parser->refs =& $this->refs; 
    7584          $data[] = $parser->parse($this->getNextEmbedBlock()); 
    7685        } 
     
    8392      { 
    8493        $key = sfYamlInline::parseScalar($values['key']); 
     94 
     95        if ('<<' === $key) 
     96        { 
     97          if (isset($values['value']) && '*' === substr($values['value'], 0, 1)) 
     98          { 
     99            $isInPlace = substr($values['value'], 1); 
     100            if (!array_key_exists($isInPlace, $this->refs)) 
     101            { 
     102              throw new InvalidArgumentException(sprintf('Reference "%s" does not exist on line %s.', $isInPlace, $this->currentLine)); 
     103            } 
     104          } 
     105          else 
     106          { 
     107            throw new InvalidArgumentException(sprintf('In place substitution must point to a reference on line %s.', $this->currentLine)); 
     108          } 
     109        } 
     110        else if (isset($values['value']) && preg_match('#^&(?P<ref>\w+) *(?P<value>.*)#', $values['value'], $matches)) 
     111        { 
     112          $isRef = $matches['ref']; 
     113          $values['value'] = $matches['value']; 
     114        } 
    85115 
    86116        // hash 
     
    96126            $c = $this->getRealCurrentLineNb() + 1; 
    97127            $parser = new sfYamlParser($c); 
     128            $parser->refs =& $this->refs; 
    98129            $data[$key] = $parser->parse($this->getNextEmbedBlock()); 
    99130          } 
     
    101132        else 
    102133        { 
    103           $data[$key] = $this->parseValue($values['value']); 
     134          if ($isInPlace) 
     135          { 
     136            $data = $this->refs[$isInPlace]; 
     137          } 
     138          else 
     139          { 
     140            $data[$key] = $this->parseValue($values['value']); 
     141          } 
    104142        } 
    105143      } 
     
    114152        throw new InvalidArgumentException(sprintf('Unable to parse line %d (%s).', $this->getRealCurrentLineNb(), $this->currentLine)); 
    115153      } 
     154 
     155      if ($isRef) 
     156      { 
     157        $this->refs[$isRef] = end($data); 
     158      } 
    116159    } 
    117160 
     
    227270  protected function parseValue($value) 
    228271  { 
     272    if ('*' === substr($value, 0, 1)) 
     273    { 
     274      if (false !== $pos = strpos($value, '#')) 
     275      { 
     276        $value = substr($value, 1, $pos - 2); 
     277      } 
     278      else 
     279      { 
     280        $value = substr($value, 1); 
     281      } 
     282 
     283      if (!array_key_exists($value, $this->refs)) 
     284      { 
     285        throw new InvalidArgumentException(sprintf('Reference "%s" does not exist (%s).', $value, $this->currentLine)); 
     286      } 
     287      return $this->refs[$value]; 
     288    } 
     289 
    229290    if (preg_match('/^(?P<separator>\||>)(?P<modifiers>\+|\-|\d+|\+\d+|\-\d+|\d+\+|\d+\-)?(?P<comments> +#.*)?$/', $value, $matches)) 
    230291    { 
  • branches/dwhittle/1.1/test/unit/util/fixtures/yaml/YtsAnchorAlias.yml

    r7989 r8133  
    1414    - Oren 
    1515    - *showell 
    16 python: | 
    17     [ 
    18         [ 'Steve', 'Clark', 'Brian', 'Oren', 'Steve'] 
    19     ] 
    20 ruby-setup: | 
    21     showell = 'Steve' 
    22 ruby: | 
    23     [ showell, 'Clark', 'Brian', 'Oren', showell ] 
    2416php: | 
    25     array('&showell Steve', 'Clark', 'Brian', 'Oren', '*showell') 
     17    array('Steve', 'Clark', 'Brian', 'Oren', 'Steve') 
     18 
    2619--- 
    27 #test: Alias of a Mapping 
    28 #brief: > 
    29 #    An alias can be used on any item of data, including 
    30 #    sequences, mappings, and other complex data types. 
    31 #yaml: | 
    32 #    - &hello 
    33 #        Meat: pork 
    34 #        Starch: potato 
    35 #    - banana 
    36 #    - *hello 
    37 #python: | 
    38 #    [ 
    39 #        [ 
    40 #            {'Meat': 'pork', 'Starch': 'potato'}, 
    41 #            'banana', 
    42 #            {'Meat': 'pork', 'Starch': 'potato'}, 
    43 #        ] 
    44 #    ] 
    45 #ruby-setup: | 
    46 #    hello = { 'Meat' => 'pork', 'Starch' => 'potato' } 
    47 #ruby: | 
    48 #    [ 
    49 #      hello, 
    50 #      'banana', 
    51 #      hello 
    52 #    ] 
    53 #php: | 
    54 #    array(array('Meat' => 'pork', 'Starch' => 'potato')) 
     20test: Alias of a Mapping 
     21brief: > 
     22    An alias can be used on any item of data, including 
     23    sequences, mappings, and other complex data types. 
     24yaml: | 
     25    - &hello 
     26        Meat: pork 
     27        Starch: potato 
     28    - banana 
     29    - *hello 
     30php: | 
     31    array(array('Meat'=>'pork', 'Starch'=>'potato'), 'banana', array('Meat'=>'pork', 'Starch'=>'potato')) 
  • branches/dwhittle/1.1/test/unit/util/fixtures/yaml/YtsSpecificationExamples.yml

    r7927 r8133  
    215215---  
    216216test: Node for Sammy Sosa appears twice in this document  
    217 todo: true 
    218217spec: 2.10  
    219218yaml: |  
     
    226225      - *SS # Subsequent occurance  
    227226      - Ken Griffey  
    228 perl: |  
    229   {   
    230     'hr' => [ 'Mark McGwire', 'Sammy Sosa' ],  
    231     'rbi' => [ 'Sammy Sosa', 'Ken Griffey' ]   
    232   }  
    233 python: |  
    234    [{   
    235       'hr': [ 'Mark McGwire', 'Sammy Sosa' ],  
    236       'rbi': [ 'Sammy Sosa', 'Ken Griffey' ]  
    237    }]  
    238 ruby: |  
    239    {   
    240       'hr' =>  
    241          [ 'Mark McGwire', 'Sammy Sosa' ],  
    242       'rbi' =>  
    243          [ 'Sammy Sosa', 'Ken Griffey' ]  
    244    }  
    245 syck: | 
    246   struct test_node seq1[] = { 
    247       { T_STR, 0, "Mark McGwire" }, 
    248       { T_STR, 0, "Sammy Sosa" }, 
    249       end_node 
    250   }; 
    251   struct test_node seq2[] = { 
    252       { T_STR, 0, "Sammy Sosa" }, 
    253       { T_STR, 0, "Ken Griffey" }, 
    254       end_node 
    255   }; 
    256   struct test_node map[] = { 
    257       { T_STR, 0, "hr" }, 
    258           { T_SEQ, 0, 0, seq1 }, 
    259       { T_STR, 0, "rbi" }, 
    260           { T_SEQ, 0, 0, seq2 }, 
    261       end_node 
    262   }; 
    263   struct test_node stream[] = { 
    264       { T_MAP, 0, 0, map }, 
    265       end_node 
    266   }; 
    267   
     227php: |  
     228   array( 
     229      'hr' => 
     230         array('Mark McGwire', 'Sammy Sosa'), 
     231      'rbi' => 
     232         array('Sammy Sosa', 'Ken Griffey') 
     233   ) 
    268234---  
    269235test: Mapping between sequences  
     
    737703--- 
    738704test: Invoice 
    739 todo: true 
     705dump_skip: true 
    740706spec: 2.27 
    741707yaml: | 
     
    755721  ship-to: *id001 
    756722  product: 
    757       - sku         : BL394D 
     723      -  
     724        sku         : BL394D 
    758725        quantity    : 4 
    759726        description : Basketball 
    760727        price       : 450.00 
    761       - sku         : BL4438H 
     728      -  
     729        sku         : BL4438H 
    762730        quantity    : 1 
    763731        description : Super Hoop 
     
    769737    Backup contact is Nancy 
    770738    Billsmer @ 338-4338. 
    771 ruby-setup: | 
    772   YAML.add_domain_type( "clarkevans.com,2002", "invoice" ) { |type, val| val } 
    773   id001 = { 'given' => 'Chris', 'family' => 'Dumars', 'address' => 
    774   { 'lines' => "458 Walkman Dr.\nSuite #292\n", 'city' => 'Royal Oak', 
    775     'state' => 'MI', 'postal' => 48046 } } 
    776 ruby: | 
    777   { 
    778      'invoice' => 34843, 'date' => Date.new( 2001, 1, 23 ), 
    779      'bill-to' => id001, 'ship-to' => id001, 'product' => 
    780        [ { 'sku' => 'BL394D', 'quantity' => 4, 
    781            'description' => 'Basketball', 'price' => 450.00 }, 
    782          { 'sku' => 'BL4438H', 'quantity' => 1, 
    783            'description' => 'Super Hoop', 'price' => 2392.00 } ], 
     739php: | 
     740  array( 
     741     'invoice' => 34843, 'date' => mktime(0, 0, 0, 1, 23, 2001), 
     742     'bill-to' =>  
     743      array( 'given' => 'Chris', 'family' => 'Dumars', 'address' => array( 'lines' => "458 Walkman Dr.\nSuite #292\n", 'city' => 'Royal Oak', 'state' => 'MI', 'postal' => 48046 ) ) 
     744     , 'ship-to' =>  
     745      array( 'given' => 'Chris', 'family' => 'Dumars', 'address' => array( 'lines' => "458 Walkman Dr.\nSuite #292\n", 'city' => 'Royal Oak', 'state' => 'MI', 'postal' => 48046 ) ) 
     746     , 'product' => 
     747       array( 
     748        array( 'sku' => 'BL394D', 'quantity' => 4, 'description' => 'Basketball', 'price' => 450.00 ), 
     749        array( 'sku' => 'BL4438H', 'quantity' => 1, 'description' => 'Super Hoop', 'price' => 2392.00 ) 
     750      ), 
    784751     'tax' => 251.42, 'total' => 4443.52, 
    785      'comments' => "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338.\n" } 
     752     'comments' => "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338.\n" 
     753  ) 
    786754--- 
    787755test: Log file 
     
    10471015---  
    10481016test: Overriding anchors  
    1049 todo: true 
    10501017yaml: |  
    10511018  anchor : &A001 This scalar has an anchor.  
     
    10541021   repeated use of this value. 
    10551022  alias : *A001 
    1056 ruby: |  
    1057   { 'anchor' => 'This scalar has an anchor.',   
    1058     'override' => "The alias node below is a repeated use of this value.\n",   
    1059     'alias' => "The alias node below is a repeated use of this value.\n" }  
    1060 syck: | 
    1061   struct test_node map[] = { 
    1062       { T_STR, 0, "anchor" }, 
    1063           { T_STR, 0, "This scalar has an anchor." }, 
    1064       { T_STR, 0, "override" }, 
    1065           { T_STR, 0, "The alias node below is a repeated use of this value.\n" }, 
    1066       { T_STR, 0, "alias" }, 
    1067           { T_STR, 0, "The alias node below is a repeated use of this value.\n" }, 
    1068       end_node 
    1069   }; 
    1070   struct test_node stream[] = { 
    1071       { T_MAP, 0, 0, map }, 
    1072       end_node 
    1073   }; 
    1074   
     1023php: |  
     1024  array( 'anchor' => 'This scalar has an anchor.', 
     1025    'override' => "The alias node below is a repeated use of this value.\n", 
     1026    'alias' => "The alias node below is a repeated use of this value.\n" ) 
    10751027---  
    10761028test: Flow and block formatting  
  • branches/dwhittle/1.1/test/unit/util/fixtures/yaml/index.yml

    r7989 r8133  
    22- sfTests 
    33- sfObjects 
     4- sfMergeKey 
    45- YtsAnchorAlias 
    56- YtsBasicTests 
  • branches/dwhittle/1.1/test/unit/util/sfYamlParserTest.php

    r7989 r8133  
    1212require_once(dirname(__FILE__).'/../../../lib/util/sfYamlParser.class.php'); 
    1313 
    14 $t = new lime_test(136, new lime_output_color()); 
     14$t = new lime_test(138, new lime_output_color()); 
     15 
    1516$parser = new sfYamlParser(); 
    1617