Skip to content

Commit

Permalink
Added autoloading of Mage in Laravel. Fixes #4
Browse files Browse the repository at this point in the history
  • Loading branch information
Wildhoney committed Aug 30, 2013
1 parent f605f59 commit c5c83d4
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 23 deletions.
2 changes: 1 addition & 1 deletion api/app/config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
|
*/

'key' => 'llUcLdw8v9nl6uEzYDW5uwGRRRJkpIOV',
'key' => 'llUcLdw8v9nl6kEzYDW5uwGRRRJkpIOV',

/*
|--------------------------------------------------------------------------
Expand Down
9 changes: 9 additions & 0 deletions api/app/controllers/MageController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

class MageController extends BaseController {

public function __construct() {
Mage::app('default');
}

}
23 changes: 23 additions & 0 deletions api/app/controllers/ProductsController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

class ProductsController extends MageController {

public function all() {

$products = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*');
$collection = array();

foreach ($products as $product) {

$collection[] = array(
'name' => $product->getName(),
'price' => $product->getPrice()
);

}

return Response::json($collection);

}

}
11 changes: 7 additions & 4 deletions api/app/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
|
*/

Route::get('/', function()
{
return View::make('hello');
});
//Route::get('/', 'HomeController@showWelcome');
Route::get('/products/all', 'ProductsController@all');
//Route::get('/', function()
//{
//// return View::make('hello');
// return Route::get('/', 'HomeController@showWelcome');
//});
17 changes: 0 additions & 17 deletions api/app/tests/ExampleTest.php

This file was deleted.

11 changes: 11 additions & 0 deletions api/app/tests/ProductsControllerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

class ProductsControllerTest extends TestCase {

public function testBasicExample()
{
$crawler = $this->client->request('GET', '/products/all');
$this->assertTrue($this->client->getResponse()->isOk());
}

}
1 change: 1 addition & 0 deletions api/app/views/json.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ye...
5 changes: 4 additions & 1 deletion api/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php"
]
],
"psr-0": {
"Mage": "../magento/app"
}
},
"scripts": {
"post-install-cmd": [
Expand Down

0 comments on commit c5c83d4

Please sign in to comment.