Delicious Bookmark this on Delicious Share on Facebook SlashdotSlashdot It! Digg! Digg



PHP : Function Reference : Object Aggregation/Composition Functions : aggregate_info

aggregate_info

Gets aggregation information for a given object ()
array aggregate_info ( object object )

Example 1626. Using aggregate_info()

<?php

class Slicer {
   var
$vegetable;

   function
Slicer($vegetable)
   {
       
$this->vegetable = $vegetable;
   }

   function
slice_it($num_cuts)
   {
       echo
"Doing some simple slicing\n";
       for (
$i=0; $i < $num_cuts; $i++) {
           
// do some slicing
       
}
   }
}

class
Dicer {
   var
$vegetable;
   var
$rotation_angle = 90;   // degrees

   
function Dicer($vegetable)
   {
       
$this->vegetable = $vegetable;
   }

   function
dice_it($num_cuts)
   {
       echo
"Cutting in one direction\n";
       for (
$i=0; $i < $num_cuts; $i++) {
           
// do some cutting
       
}
       
$this->rotate($this->rotation_angle);
       echo
"Cutting in a second direction\n";
       for (
$i=0; $i < $num_cuts; $i++) {
           
// do some more cutting
       
}
   }

   function
rotate($deg)
   {
       echo
"Now rotating {$this->vegetable} {$deg} degrees\n";
   }

   function
_secret_super_dicing($num_cuts)
   {
       
// so secret we cannot show you ;-)
   
}
}

$obj = new Slicer('onion');
aggregate($obj, 'Dicer');
print_r(aggregate_info($obj));
?>

The above example will output:

Array
(
   [dicer] => Array
       (
           [methods] => Array
               (
                   [0] => dice_it
                   [1] => rotate
               )

           [properties] => Array
               (
                   [0] => rotation_angle
               )

       )

)

Change Language


Follow Navioo On Twitter
aggregate_info
aggregate_methods_by_list
aggregate_methods_by_regexp
aggregate_methods
aggregate_properties_by_list
aggregate_properties_by_regexp
aggregate_properties
aggregate
aggregation_info
deaggregate
eXTReMe Tracker