diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9a828cd --- /dev/null +++ b/.gitignore @@ -0,0 +1,21 @@ +# cache directories +Thumbs.db +*.DS_Store +*.empty + +#phpstorm project files +.idea + +#netbeans project files +nbproject + +#eclipse, zend studio, aptana or other eclipse like project files +.buildpath +.project +.settings + + +# mac deployment helpers +switch +index +.php-cs-fixer.cache diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php new file mode 100644 index 0000000..fa5e10d --- /dev/null +++ b/.php-cs-fixer.dist.php @@ -0,0 +1,44 @@ +exclude('docs/') + ->exclude('tests/') + ->exclude('vendor/') + ->in(__DIR__); + +$config = new PhpCsFixer\Config(); +$config + ->setRiskyAllowed(true) + ->setIndent("\t") + ->setLineEnding("\n") + ->setRules([ + '@PSR2' => true, + 'align_multiline_comment' => true, + 'array_syntax' => ['syntax' => 'short'], + 'binary_operator_spaces' => true, + 'blank_line_after_namespace' => true, + 'blank_line_after_opening_tag' => true, + 'cast_spaces' => ['space' => 'single'], + 'combine_nested_dirname' => true, + 'concat_space' => ['spacing' => 'one'], + 'dir_constant' => true, + 'is_null' => true, + 'list_syntax' => ['syntax' => 'short'], + 'modernize_types_casting' => true, + 'no_alias_functions' => true, + 'no_null_property_initialization' => true, + 'no_whitespace_before_comma_in_array' => true, + 'phpdoc_add_missing_param_annotation' => ['only_untyped' => false], + 'phpdoc_order' => true, + 'phpdoc_scalar' => true, + 'phpdoc_types_order' => true, + 'psr_autoloading' => true, + 'ternary_operator_spaces' => true, + 'ternary_to_null_coalescing' => true, + 'trim_array_spaces' => true, + 'visibility_required' => true, + 'whitespace_after_comma_in_array' => true, + ]) + ->setFinder($finder); + +return $config; \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..3ea9393 --- /dev/null +++ b/LICENSE @@ -0,0 +1,31 @@ +The PRADO framework and the included examples are free software. +They are released under the terms of the following BSD License. + +Copyright 2004-2021, The PRADO Group (https://github.com/pradosoft) +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +- Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. + +- Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +- Neither the name of the of the copyright holder nor the names of its +contributors may be used to endorse or promote products derived from this +software without specific prior written permission. + + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..e6a25c0 --- /dev/null +++ b/README.md @@ -0,0 +1,61 @@ +PRADO Composer Extension example +===================================== + +This is a Minimal base composer extension for PRADO Framework. This automatically adds the Pages directory to the TPageService::onAdditionalPagePaths and loads the errorMessages. + + +Installation +------------ + +The preferred way to install this extension is through [composer](http://getcomposer.org/download/). + +Either run + +``` +php composer.phar require --prefer-dist pradosoft/prado-composer-extension "*" +``` + +or add + +``` +"pradosoft/prado-composer-extension": "*" +``` + +to the require section of your `composer.json` file. + + +Setup +----- + +Once the extension is installed, load the extension in your Prado application config by specifying the extension name as a module id. + +Add the module to the application configuration without the class. For example, like this: + +```xml + + + +``` + + +Usage +----- + +Add the following Application Parameter to your application configuration: PluginContentId. for example like this: + +```xml + + + +``` + +Set the PluginContentId to the name of the main TPlaceholderContent ID of your layout so the plugins can be loaded properly. + +Follow the panel link to http://application/web/index.php?page=Example +On the index page you'll see extension specific content. + + +Extension +--------- + +The composer.json uses a "type" of "prado4-extension" and will load the class from ["extra"]["bootstrap"] for the module id/package name. Use these specific parameters and values to designate and use your own prado composer extension. \ No newline at end of file diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..13bef8d --- /dev/null +++ b/composer.json @@ -0,0 +1,30 @@ +{ + "name": "pradosoft/prado-composer-extension", + "version": "v1.0.0", + "version_normalized": "1.0.0.0", + "description": "The Base example PRADO Composer Extension", + "license": "BSD-3-Clause", + "type": "prado4-extension", + "keywords": [ "prado", "framework", "example", "extension"], + "homepage": "https://github.com/pradosoft/prado-composer-extension", + "authors": [ + { + "name": "Brad Anderson", + "email": "belisoful@icloud.com", + "role": "Developer", + "homepage": "https://github.com/belisoful" + } + ], + "notification-url": "https://packagist.org/downloads/", + "autoload": { + "psr-4": { + "PradoComposerExtension\\": "src" + } + }, + "require": { + "pradosoft/prado" : "4.2.0" + }, + "extra": { + "bootstrap": "PradoComposerExtension\\MainModule" + } +} diff --git a/src/MainModule.php b/src/MainModule.php new file mode 100644 index 0000000..16f7395 --- /dev/null +++ b/src/MainModule.php @@ -0,0 +1,53 @@ + + * @link https://github.com/pradosoft/prado-composer-extension + * @license https://github.com/pradosoft/prado-composer-extension/blob/master/LICENSE + * @package PradoComposerExtension + */ +namespace PradoComposerExtension; + +use Prado\TPropertyValue; +use Prado\Util\TPluginModule; + +/** + * MainModule class. + * + * main example bootstrap module class + * + * @author Brad Anderson + * @package PradoComposerExtension + * @since 1.0.0 + */ +class MainModule extends TPluginModule +{ + /** @var null|string property A */ + private $_propertya; + + /** + * Initializes the module, call the parent:init. + * @param null|array|TXmlElement $config + */ + public function init($config) + { + parent::init($config); + } + + /** + * @return null|string gets the Property A from the module + */ + public function getPropertyA() + { + return $this->_propertya; + } + + /** + * @param null|string $v sets the Property A from the module + */ + public function setPropertyA($v) + { + $this->_propertya = TPropertyValue::ensureString($v); + } +} diff --git a/src/Pages/Example.page b/src/Pages/Example.page new file mode 100644 index 0000000..2829715 --- /dev/null +++ b/src/Pages/Example.page @@ -0,0 +1,3 @@ +> + Page from Prado-Composer-Extension. + diff --git a/src/errorMessages.txt b/src/errorMessages.txt new file mode 100644 index 0000000..a039576 --- /dev/null +++ b/src/errorMessages.txt @@ -0,0 +1 @@ +my_error_condition = Prado Composer Extension threw an exception \ No newline at end of file