Kohana 3.3 multi language - kohana

Following the tutorial # http://kerkness.ca/kowiki/doku.php?id=example_of_a_multi-language_website
I need to override the Request class, but there is no instance method.
What do i need to change to get it working in kohana v3.3 ?
Thx in advance!

The use of Request::instance() was replaced with Request::$current since Kohana 3.2, so you should write this in top of your Request class:
class Request extends Kohana_Request {
public static function current( & $uri = TRUE)
{
...

Related

What is the easiest way to start pagination results at 1 with Spring Data JPA?

In some other places I saw people suggesting to set:
spring.data.web.pageable.one-indexed-parameters=true
However, this is not changing anything in the behavior of my application. I've put this on the properties file of my SpringBoot application.
Am I missing something ?
You can use the PageableDefault annotation, i.e. #PageableDefault(page = 1) on your Controller method, e.g.:
#RestController
public class Controller {
public Page< DataEntity > getEntities(#PageableDefault(page = 1)Pageable pageable){
//repository call here...
}
}

How to inject or import libraries in the tapestry core stack to a component?

I'm using tapestry 5.4.1. I have a component with a module that requires prototype. I know prototype is available in the core stack. However how do I import this as a dependency.
My module:
define(["prototype"], function(container, link) {
return new Ajax.PeriodicalUpdater(container, link, {
method : 'post', frequency : 5, decay : 1
});
});
I tried adding this to the class but the path cannot be resolved
#Import(library = {"prototype.js"})
public class Update {
Tried injecting the asset and adding it to the environmental javascriptsupport but it somehow looks for it in the wrong location.
#Inject
#Path("classpath:META-INF/assets/tapestry5/prototype.js")
private Asset prototype;
and
javascriptSupport.importJavaScriptLibrary(prototype);
javascriptSupport.require("update").with(container, getLink());
I don't want to hard code the url with the generated hash.
/assets/meta/z67bxxxx/tapestry5/scriptaculous_1_9_0/prototype.js
Anything I am missing here? Any help would be appreciated.
Make sure you define correct infrastructure in your AppModule
#ApplicationDefaults
public static void contributeApplicationDefaults(MappedConfiguration<String, Object> configuration) {
configuration.add(SymbolConstants.JAVASCRIPT_INFRASTRUCTURE_PROVIDER, "prototype");
}
You don't have to specify dependency clearly ["prototype"].

Magento multiversion module Error class Mage_Catalog_Model_Resource_Product_Option not found

I'm trying to create module for magento. It use my own class
class Myfirm_Extname_Model_Mysql4_Product_Option extends Mage_Catalog_Model_Resource_Product_Option
In magento 1.7 all works fine, in 1.5 - error: Error class Mage_Catalog_Model_Resource_Product_Option not found.
How can I make class that will be inherited from Mage_Catalog_Model_Resource_Product_Option or Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Option depending on the version of magento?
I solved this prodblem.
protected function _getResource() {
if (version_compare(Mage::getVersion(), '1.6.0', '<')) {
$this->_resourceName = $this->_resourceName.'_oldversion';
}
if (empty($this->_resourceName)) {
Mage::throwException(Mage::helper('core')->__('Resource is not set.'));
}
return Mage::getResourceSingleton($this->_resourceName);
}
And then create 2 resource model class for old version of magento and new

Kohana ErrorException [ Fatal Error ]: Call to undefined method Request::redirect()

I'm using Kohana 3.3.0 and i have a controller which is supposed to save blog articles to a database then redirect to the homepage, my code is as follows:-
class Controller_Article extends Controller {
const INDEX_PAGE = 'index.php/article';
public function action_post() {
$article_id = $this->request->param('id');
$article = new Model_Article($article_id);
$article->values($_POST); // populate $article object from $_POST array
$article->save(); // saves article to database
$this->request->redirect(self::INDEX_PAGE);
}
The article saves to database but the redirect line gives the error:-
ErrorException [ Fatal Error ]: Call to undefined method Request::redirect()
Please let me know how i can do the redirect.
Thanks
You're getting the Exception because as of Kohana 3.3, Request no longer has the method redirect.
You can fix your example by replacing
$this->request->redirect(self::INDEX_PAGE);
with
HTTP::redirect(self::INDEX_PAGE);
Yeah, Request::redirect is not longer exists. So in order to easily to move from 3.2 to 3.3 I extented Kohana_Request class and added redirect method. Just create Request.php in classes folder and write
class Request extends Kohana_Request {
/**
* Kohana Redirect Method
* #param string $url
*/
public function redirect($url) {
HTTP::redirect($url);
}
}
So you will be able to use both Request::redirect and $this->request->redirect
in your controller $this->redirect('page');
$this->redirect('article/index');

EF 5 Re-Use entity configuration

I'm trying to re-use some of the model configurations on several entities that implements a interface.
Check this code:
public static void ConfigureAsAuditable<T>(this EntityTypeConfiguration<T> thisRef)
where T : class, IAuditable
{
thisRef.Property(x => x.CreatedOn)
.HasColumnName("utctimestamp")
.IsRequired();
thisRef.Property(x => x.LastUpdate)
.HasColumnName("utclastchanged")
.IsRequired();
} // ConfigureAsAuditable
as you can see I'm trying to call the extension method "ConfigureAsAuditable" on my onmodelcreating method like this:
EntityTypeConfiguration<Account> conf = null;
conf = modelBuilder.Entity<Account>();
conf.ToTable("dbo.taccount");
conf.ConfigureAsAuditable();
When debugging i get this exception:
The property 'CreatedOn' is not a declared property on type
'Account'. Verify that the property has not been explicitly excluded
from the model by using the Ignore method or NotMappedAttribute data
annotation. Make sure that it is a valid primitive property.
Thanks in advance :)
PD:
I'm using EF 5-rc, VS 2011 and .NET Framework 4.5
I think a better approach would be to implement your own derived version of EntityTypeConfiguration. For example:
public class MyAuditableConfigurationEntityType<T> : EntityTypeConfiguration<T>
where T : class, IAuditable{
public bool IsAuditable{get;set;}
}
Then, when building your model, use that new type:
var accountConfiguration = new MyAuditableConfigurationEntityType<Account>();
accountConfiguration.IsAuditable = true; // or whatever you need to set
accountConfiguration.(HasKey/Ignore/ToTable/Whatever)
modelBuilder.Configurations.Add(accountConfiguration);

Resources