Post by Sheldmandu » Sat Jul 03, 2010 8:42 pm

Anyone who wants autocompletion in NetBeans (and most likely will work in Eclipse PDT too) just add the following above abstract class Controller in system/engine/controller.php

/**
* @property string $id
* @property string $template
* @property array $children
* @property array $data
* @property string $output
* @property Loader $load
* @property Config $config
* @property DB $db
* @property Log $log
* @property Request $request
* @property Response $response
* @property Cache $cache
* @property Url $url
* @property Document $document
* @property Language $language
* @property Customer $customer
* @property Currency $currency
* @property Tax $tax
* @property Weight $weight
* @property Measurement $measurement
* @property Cart $cart
* @property ModelToolSeoUrl $model_seo_url
*/

This will make life a hell of a lot easier for you as you don't need to guess what all the available properties and methods of those objects are and you can use Ctrl+space to invoke code completion. Also, you can add similar comments above the specific controllers and define properties like model_catalog_category etc so that you can take advantage of code completion on the models too.

New member

Posts

Joined
Sat Feb 27, 2010 10:43 am

Post by ckonig » Thu Mar 28, 2013 5:19 am

This is awesome! Exactly what i needed.

If anybody is wondering, how he can have code completion for the models as well...
you could type them all in manually, or use the following generator script:

Code: Select all

public function models() {
        $files = glob(DIR_APPLICATION . 'model/*/*.php');
        foreach ($files as $file) {
            $data = explode('/', dirname($file));
            $permission = ' * @property Model' . ucfirst(end($data)) . ucfirst(basename($file, '.php')) . ' $model_' . end($data) . '_' . basename($file, '.php');
            echo $permission . '<br/>';
        }
    }
Just copy it into one of your controllers, run it, and copy the output to your engine/controller base class.
You will have to run it once in the catalog and once in the admin section. Apparently this produces some ambiguity, but netbeans can handle it quite well.

User avatar
Active Member

Posts

Joined
Wed Feb 16, 2011 4:26 pm
Location - Netherlands

Post by rph » Thu Mar 28, 2013 10:29 am

Nice!

-Ryan


rph
Expert Member

Posts

Joined
Fri Jan 08, 2010 5:05 am
Location - Lincoln, Nebraska

Post by mithereal » Tue May 21, 2013 2:50 am

<?php
require 'config.php';
$properties=array();

$properties[]='string $id';
$properties[]='string $template';
$properties[]='array $children';
$properties[]='array $data';
$properties[]='string $output';
$properties[]='Loader $load';
$properties[]='Config $config';
$properties[]='DB $db';
$properties[]='Log $log';
$properties[]='Request $request';
$properties[]='Response $response';
$properties[]='Cache $cache';
$properties[]='Url $url';
$properties[]='Document $document';
$properties[]='Language $language';
$properties[]='Customer $customer';
$properties[]='Currency $currency';
$properties[]='Tax $tax';
$properties[]='Weight $weight';
$properties[]='Measurement $measurement';
$properties[]='Cart $cart';
$properties[]='ModelToolSeoUrl $model_seo_url';



function getModels($basedir=DIR_APPLICATION) {
$permission =array();
$files = glob($basedir. 'model/*/*.php');
foreach ($files as $file) {
$data = explode('/', dirname($file));
$permission[] = 'Model' . ucfirst(end($data)) . ucfirst(basename($file, '.php')) . ' $model_' . end($data) . '_' . basename($file, '.php');

}
return $permission;
}

$adminurl=str_ireplace('catalog/','admin/',DIR_APPLICATION);
$catalog_models=getModels();
$admin_models=getModels($adminurl);
$textToInsert=array_merge($properties,$catalog_models);
$textToInsert=array_merge($textToInsert,$admin_models);
$textToInsert=array_unique($textToInsert);

echo '<h3>Place the following code above abstract class Controller in your system/engine/controller.php file</h3><hr>';
echo '/**','<br>';
foreach($textToInsert as $val)
{

echo '* @property '.$val.'<br>';
}
echo '**/','<br>';
echo '<hr>';
?>
I also have created an extension for this

User avatar
Newbie

Posts

Joined
Fri Mar 22, 2013 6:16 am
Who is online

Users browsing this forum: No registered users and 5 guests