Using PHPPixies Nested Set requires being careful.
-
You can only add new (not "loaded()") categories into set. For this reason I've added
setIsLoaded
method to theBaseModel
class to be able to temporarily mark model as new.Category
in turn is also derived fromBaseModel
.// $category - existing category in DB $category->setIsLoaded(false); $category->nested->prepare_append($parent); $category->setIsLoaded(true); $category->save();
-
If you operate on many categories, always refresh them before processing, because
lpos
,rpos
anddepth
fields can be obsolete. PHPixie doesn't provides this capability, so therefresh()
method was added.// ... Do something with other categories .... $rootCategory->refresh(); // !!! Important !!! $rootCategory->parent = 0; $rootCategory->save();
Hackazon is self-contained regarding AMF. That means you just have install hackazon and just use AMF service included in it. But to develop or maintain AMF functionality you have to complete several steps.
-
Clone https://github.com/silexlabs/amfphp-2.0 repository.
-
Create VirtualHost (e.g. backoffice.dev) pointing to the amfphp-2.0/BackOffice as a web root.
-
Modify class Amfphp_BackOffice_Config. Set
$amfphpEntryPointPath
to your local VHost for hackazon (with path) and credentials://... public $amfphpEntryPointPath = 'http://hackazon.dev/amf'; //... public function __construct() { // ... $this->backOfficeCredentials['admin'] = 'admin'; // ... }
-
Run backoffice.dev (or whatever you named it) in browser.
-
In Service Browser you can test your backend methods using many connection types (JSON, Flash, etc.)
-
When you've finished developing and testing your features, go to Client Generator and generate test client in needed format.
-
For JS service format modify web/js/amf/services.js file with generated data (do NOT replace completely).
-
For flash or any other format modifications are up to you.
Services are plain PHP classes located at /modules/amfphp/classes/AmfphpModule/Services
.
To use Pixie inside service just include Pixifiable
trait into it.
class CouponService
{
use Pixifiable;
// ....
}
Special plugin will automatically bind Pixie to your service.
Also, it's recommended to add PHPDoc annotations to your services and their methods, as AMFPHP reads them.
AMFPHP backend is integrated in Hackazon, and accessible via URL <hackazon_url>/amf_back_office/index.php
.
All inconsistencies have been fixed (ZIP generating, htaccecc, etc.), so it should work OK in Hackazon.
Generated files reside in $DOC_ROOT/web/amf_back_office/ClientGenerator/Generated
.
Access to backend is left as in previous section: admin:admin.
-
Download and unpack Flex SDK (>= v4.6):
http://www.adobe.com/devnet/flex/flex-sdk-download.html
-
Uninstall flash player and install its debuggable version, browser plugin and separate player:
https://www.adobe.com/support/flashplayer/downloads.html#fp15
-
Create flash/flex project in your IDE of choice, based on downloaded For example, IDEA Ultimate allows to create module inside the top-level Hackazon module.
-
Add dependencies:
- \subprojects\Amf\lib - all extended libs, including code generated by AMFPHP generator (its common for all widgets)
- MX library from flex sdk: flex_sdk_4.6/frameworks/libs/mx/mx.swc
-
Just run (or fix inconsistencies dependent on your config, and then run)
-
By default all output files should go into
/web/out/<widget_name>
to be accessible via browser. It gives the opportunity to test JS to AS communication, because for local files it's denied. -
After building and testing you should copy swfs into /web/swf folder
It's better to use some tutorial for setting up the environment for Android either from the google website, or any other. But here are the most important steps:
-
Install and set up Android SDK in your IDE (Or use Android build for Eclipse or Android Studio)
-
Set the path
subprojects\android\hackazon
as a project root. -
Set up the AVR virtual device for testing purposes.
-
Add jar's from
jars
folder to project build paths. -
Create run configuration in your IDE which runs the AVR and when it's ready, installs and runs the application on virtual device.
-
When you feel that the app is ready, you can test it on your Android device by plugging it to the PC and configuring run configuration.
-
Just take the hackazon.apk file from
\subprojects\android\hackazon\out\production\hackazon\com
. Profit!
PS: To deploy the app to some kind of app store the app have to be signed. IDE helps with this task.