Skip to content

Commit

Permalink
Start react web app, adjust controller to receive public store info
Browse files Browse the repository at this point in the history
  • Loading branch information
portchris committed Feb 22, 2019
1 parent c364789 commit 90c55fa
Show file tree
Hide file tree
Showing 11 changed files with 88 additions and 55 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "src/app/design/frontend/rwd_faceandfigure/default/faceandfigure"]
path = src/app/design/frontend/rwd_faceandfigure/default/faceandfigure
url = [email protected]:portchris/faceandfiguresalon.git
6 changes: 1 addition & 5 deletions env/nginx/webserver/global/api.conf
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
# M1 API
location /api {
rewrite ^/api/rest /api.php?type=rest last;
rewrite ^/api/v2_soap /api.php?type=v2_soap last;
rewrite ^/api/soap /api.php?type=soap last;
rewrite ^/api/xmlrpc /api.php?type=xmlrpc last;
rewrite ^/api.php/ /api.php last;
rewrite ^/api/(\w+).*$ /api.php?type=$1 last;
}
10 changes: 10 additions & 0 deletions env/php72/scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,17 @@ find $SRC/media/ -type f -exec chmod 600 {} +
find $SRC/var/ -type d -exec chmod 700 {} +
find $SRC/media/ -type d -exec chmod 700 {} +
chmod 700 $SRC/includes

# NPM setup
chmod 600 $SRC/includes/config.php
if [ ! -d /home/www/.npm ]; then
mkdir /home/www/.npm
fi
if [ ! -d /home/www/.config ]; then
mkdir /home/www/.config
fi
chown -R www:www /home/www/.npm
chown -R www:www /home/www/.config

# Start CRON service
service cron start
Expand Down
File renamed without changes.
33 changes: 27 additions & 6 deletions src/app/code/local/NaturalRemedyCo/FaceAndFigure/Block/Header.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,23 @@ class NaturalRemedyCo_FaceAndFigure_Block_Header extends Mage_Core_Block_Templat
*/
const REACT_COMPONENT = "header";

/**
* @var Mage_Core_Design_Package
*/
protected $_design;


/**
* @var Mage_Core_Model_Store
*/
protected $_store;

public function __construct()
/**
* Magento contructor
*/
public function _construct()
{
$this->_design = Mage::getSingleton('core/design_package');
$this->_store = Mage::app()->getStore();
}

Expand All @@ -28,26 +38,37 @@ public function __construct()
*/
public function getBlockConfig()
{
return json_encode([
"title" => $this->_store->getFrontendName()
], true);
$logoSrc = Mage::getStoreConfig('design/header/logo_src');
return [
"title" => $this->_store->getFrontendName(),
"logo" => $this->_design->getSkinUrl($logoSrc)
];
}

/**
* @return string
*/
public function getReactComponent()
{
return Mage::getSingleton('core/design_package')->getSkinUrl() . "js" . DS . "components" . DS . self::REACT_COMPONENT . ".js";
return $this->_design->getSkinUrl() . "js" . DS . "components" . DS . self::REACT_COMPONENT . ".js";
}

/**
* @return array
*/
public function getComponentsRegistry()
{
return (Mage::registry('react_components', Mage::app()->getStore()->getId())) ? Mage::registry('react_components', Mage::app()->getStore()->getId()) : [];
return (Mage::registry('react_components', $this->_store->getId())) ? Mage::registry('react_components', $this->_store->getId()) : [];

}

/**
* Override default get using getChildHtml, return JSON instead
* @return JSON
*/
public function _toHtml()
{
return $this->getBlockConfig();
}
}
?>
35 changes: 0 additions & 35 deletions src/app/code/local/NaturalRemedyCo/FaceAndFigure/etc/api2.xml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,37 @@
<?php
class NaturalRemedyCo_NRCLayout_IndexController extends Mage_Core_Controller_Front_Action {
public function indexAction() {
$date = date('Y-m-d');
echo "Hello todays date is $date";
/**
* Public store inforamtion in JSON format
*
* @author Chris Rogers
* @since 2019-02-22
*/

class NaturalRemedyCo_NRCLayout_IndexController extends Mage_Core_Controller_Front_Action
{
/**
* @var Mage_Core_Model_Store
*/
protected $_store;

/**
* Magento's specific construtor (notice the single underscore)
*/
public function _construct()
{
$this->_store = Mage::app()->getStore();
}

/**
* Return store info as JSON using layout file <info_index_index>
* @return JSON
* @see Useful debugging: "Zend_Debug::dump($this->getLayout()->getUpdate()->getHandles()); exit;"
*/
public function indexAction()
{
$this->getResponse()->setHeader('Content-type', 'application/json');
$this->loadLayout();
// $this->getResponse()->setBody();
$this->renderLayout();
}
}
?>
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<use>standard</use>
<args>
<module>NaturalRemedyCo_NRCLayout</module>
<frontName>nrc_layout</frontName>
<frontName>info</frontName>
</args>
</nrc_layout>
<contacts>
Expand Down
Submodule faceandfiguresalon added at 6df4ec
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
<?xml version="1.0" encoding="UTF-8" ?>
<layout>
<page_empty>
<reference name="content">
</page_empty>
<nrc_layout_index_index>
<reference name="root">
<action method="setTemplate">
<template>faceandfigure/main.phtml</template>
</action>
<block type="faceandfigure/hero" name="hero" as="hero" template="faceandfigure/hero.phtml" before="-" />
<block type="faceandfigure/header" name="header" as="header" template="faceandfigure/header.phtml" before="hero" />
<block type="faceandfigure/main" name="main" as="main" template="faceandfigure/main.phtml" />
<block type="faceandfigure/treatments" name="treatments" as="treatments" template="faceandfigure/treatments.phtml" />
<block type="faceandfigure/contact" name="contact" as="contact" template="faceandfigure/contact.phtml" />
<block type="faceandfigure/footer" name="footer" as="footer" template="faceandfigure/footer.phtml" />
</reference>
</page_empty>
</nrc_layout_index_index>
</layout>
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@
* @since 2019-01-11 <1.0.0>
* @var NaturalRemedyCo_FaceAndFigure_Block_Hero $this
*/
?>
<div>Main</div>
$data = [
"header" => $this->getChildHtml("header")
];

echo json_encode($data, true); ?>

0 comments on commit 90c55fa

Please sign in to comment.