Dumping classes

Thursday 30 June 2011 4:18:17 pm

By : Steven E. Bailey

Here's a little script I use when I have get the info from a class or classes:

 

 <?php
require 'autoload.php';
$cli = eZCLI::instance();
$script = eZScript::instance( array( 'description' => (
          "Displays Class attributes of either [CLASS] or all classes" ),
                                     'use-session' => false,
                                     'use-modules' => true,
                                     'use-extensions' => true ) );
$script->startup();

$options = $script->getOptions( "", "[class]", array() );

$script->initialize();

eZDebug::writeDebug( $options, "options" );

if ( count( $options['arguments'] ) >= 1 )
{
        foreach ( $options['arguments'] as $identifier ) {
                if ( is_numeric( $identifier ) ) {
                        $ContentObjectClass = eZContentClass::fetch( $identifier );
                        if (is_object($ContentObjectClass)) {
                                $identifier = $ContentObjectClass->attribute('identifier');
                        } else {
                                echo "Error: Invalid class identifier: ".$identifier."\n";
                                $script->shutdown();
                                exit();
                        }
                } 
                $classList[] = eZContentClass::fetchByIdentifier($identifier,true);
        }
} else {
        $classList = eZContentClass::fetchAllClasses();
}

foreach($classList as $class) {
    if (is_object($class)) {
    echo $class->attribute('id')." <--> ".$class->attribute('name')." <--> ".$class->attribute('identifier')."\n";
    $classAttributes = eZContentClass::fetchAttributes($class->attribute( 'id'),true);
    foreach ($classAttributes as $attribute) {
        echo $attribute->attribute( "id" )."|";
        echo $attribute->attribute( "name" )."|";
        echo $attribute->attribute( "identifier" )."|";
        echo $attribute->attribute( "data_type_string" );
        if ($attribute->attribute( 'is_required' ) ){
                echo "|required";
        }
        if ($attribute->attribute( 'is_searchable' ) ){
                echo "|searchable";
        }
        if ($attribute->attribute( 'is_information_collector' ) ){
                echo "|collector";
        }
        echo "\n";
    }
    } else {
        echo $class." invalid identifier, skipping.";
   }
}
$script->shutdown();

?>
Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 29 2025 13:46:41
Script start
Timing: Jan 29 2025 13:46:41
Module start 'layout'
Timing: Jan 29 2025 13:46:41
Module start 'content'
Timing: Jan 29 2025 13:46:41
Module end 'content'
Timing: Jan 29 2025 13:46:41
Script end

Main resources:

Total runtime0.0140 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0060 589.2422151.1953
Module start 'layout' 0.00600.0020 740.437536.6250
Module start 'content' 0.00800.0046 777.062594.5781
Module end 'content' 0.01260.0013 871.640629.9766
Script end 0.0139  901.6172 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002316.5123140.0002
Check MTime0.00107.3777140.0001
Mysql Total
Database connection0.00096.752210.0009
Mysqli_queries0.001913.906130.0006
Looping result0.00000.071810.0000
Template Total0.00096.510.0009
Template load0.00064.515210.0006
Template processing0.00031.985810.0003
Override
Cache load0.00043.118910.0004
General
dbfile0.00064.410980.0001
String conversion0.00000.049640.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs